-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Atributtes and dates on anniversary day #5
Comments
pinkywafer
added a commit
that referenced
this issue
Nov 6, 2019
Thanks for this. I did indeed miss the underscores! |
pinkywafer
added a commit
that referenced
this issue
Nov 6, 2019
* closes #5 and adds date format option * add date_format config option * add date_format config option
thanks a lot again |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi,with the last upgrade i think u forgot the underscore on the new attributes,I've also seen that if it's birthday, it will mark one year less,so i edit the sensor.py changing the date format to my country too,
changes are on lines 14/15 and 70 for my format date
thanks for your work:
i tried to fix the problem with years on birthday day but i dont be able,i hope you can fix this issues in a next update,thanks again
"""Platform for sensor integration."""
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_NAME,
)
from homeassistant.helpers.entity import Entity
from datetime import datetime, date, timedelta
CONF_DATE = "date"
ATTR_YEARS_NEXT = "years_at_next_anniversary"
ATTR_YEARS_CURRENT = "current_years"
ATTR_DATE = "date"
CONF_ICON_NORMAL = "icon_normal"
CONF_ICON_TODAY = "icon_today"
CONF_ICON_TOMORROW = "icon_tomorrow"
DEFAULT_ICON_NORMAL = "mdi:calendar-clock"
DEFAULT_ICON_TODAY = "mdi:calendar-star"
DEFAULT_ICON_TOMORROW = "mdi:calendar"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_DATE): cv.date,
vol.Required(CONF_NAME): cv.string,
vol.Optional(CONF_ICON_NORMAL, default=DEFAULT_ICON_NORMAL): cv.icon,
vol.Optional(CONF_ICON_TODAY, default=DEFAULT_ICON_TODAY): cv.icon,
vol.Optional(CONF_ICON_TOMORROW, default=DEFAULT_ICON_TOMORROW): cv.icon,
})
TRACKABLE_DOMAINS = ["sensor"]
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Setup the sensor platform."""
async_add_entities([anniversaries(config)],True)
class anniversaries(Entity):
def init(self, config):
"""Initialize the sensor."""
self._name = config.get(CONF_NAME)
self._date = config.get(CONF_DATE)
self._icon_normal = config.get(CONF_ICON_NORMAL)
self._icon_today = config.get(CONF_ICON_TODAY)
self._icon_tomorrow = config.get(CONF_ICON_TOMORROW)
self._icon = self._icon_normal
self._years_next = 0
self._years_current = 0
self._state = 0
The text was updated successfully, but these errors were encountered: