Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jewish calendar sensor #16393

Merged
merged 27 commits into from
Sep 17, 2018
Merged

Jewish calendar sensor #16393

merged 27 commits into from
Sep 17, 2018

Conversation

tsvi
Copy link
Contributor

@tsvi tsvi commented Sep 3, 2018

Description:

This adds a Jewish calendar sensor to home assistant.
By default it displays the current Hebrew calendar date in English characters.

G-d willing, I'll be adding more sensors in the future and cleanup the API for hdate so the interface between Hass and hdate can be done in a cleaner fashion.
At the moment I implemented the most interesting sensors.
Also on the TODO list is changing the Hebrew date at sunset as is customary in Jewish practice.

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#6265

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: jewish_calendar
    language: <hebrew or english>
    latitude: <coordinates for given sensor>
    longitude: <coordinates for given sensor>
    disapora: <True or False>
    sensors:
      - date
      - weekly_portion
      - holiday_name
      - holyness
      - first_light
      - gra_end_shma
      - mga_end_shma
      - plag_mincha
      - first_stars

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.


from homeassistant.components.sensor import PLATFORM_SCHEMA

import homeassistant.helpers.config_validation as cv

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'homeassistant.helpers.config_validation as cv' imported but unused

https://home-assistant.io/components/sensor.jewish_calendar/
"""
import logging
from datetime import date as dt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'datetime.date as dt' imported but unused

@tsvi tsvi changed the title WIP: Jewish calendar sensor Jewish calendar sensor Sep 6, 2018
@frenck
Copy link
Member

frenck commented Sep 9, 2018

Could not find a matching PR in the documentation. Added the docs-missing label.

CONF_SENSORS = 'sensors'

DEFAULT_NAME = 'Jewish Calendar'
DEFAULT_LATITUDE = 31.778
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should default to the users location

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you already do that. In that case, please remove these as they serve no purpose.


def __init__(self, name, language, sensor_type,
latitude=DEFAULT_LATITUDE, longitude=DEFAULT_LONGITUDE,
diaspora=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be no defaults here, defaults should be set in voluptuous schema.

"""Update the state of the sensor."""
import hdate

self._date = dt_util.now().date()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to store this as an instance variable, it's only used in this method.

@ghost ghost assigned fabaff Sep 17, 2018
Copy link
Member

@fabaff fabaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🐦

@fabaff fabaff merged commit 25712f1 into home-assistant:dev Sep 17, 2018
@ghost ghost removed the in progress label Sep 17, 2018
@balloob balloob mentioned this pull request Sep 28, 2018
@tes5884
Copy link

tes5884 commented Sep 28, 2018

THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@dshanske
Copy link

Why is it disapora and not diaspora?

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Sep 30, 2018
@tsvi tsvi deleted the jcal branch October 4, 2018 10:42
@tsvi tsvi restored the jcal branch October 4, 2018 10:43
@tsvi tsvi deleted the jcal branch October 4, 2018 10:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants