Closed tabnul closed 4 years ago
Hi,
Thanks for reporting.
I think your best bet would be to create a custom actor template based on the generic
actor type, basically what the switch
actor looks like, but with the values in upper case.
I could of course include another actor type for this natively, but I think upper case on/off is quite uncommon.
BTW, can't you just use state_template
in the mqtt switch config to make the value lowercase? Seems like the cleanest solution to me while thinking about it.
Best regards Robert
Hi,
Thanks for reporting.
I think your best bet would be to create a custom actor template based on the
generic
actor type, basically what theswitch
actor looks like, but with the values in upper case.
Thanks, is there an example available for the custom actors ? Allready looked into it but was not able to figure out how this works.
I could of course include another actor type for this natively, but I think upper case on/off is quite uncommon.
BTW, can't you just use
state_template
in the mqtt switch config to make the value lowercase? Seems like the cleanest solution to me while thinking about it.
The uppercase 'issue' seems to be generic MQTT behavior (default payload IS in uppercase, i think the problem is more widespread than just the Ikea switches.
Thanks, is there an example available for the custom actors ? Allready looked into it but was not able to figure out how this works.
Ah, my bad. I meant to use the generic
actor type, not custom
.
The uppercase 'issue' seems to be generic MQTT behavior (default payload IS in uppercase, i think the problem is more widespread than just the Ikea switches.
Sure, but there is the option to provide a template for processing the MQTT state payload into a value to be set as the entity state. This option is called state_template
and a value of "{{ value|lower }}"
should do the trick.
EDIT: Corrected state_payload
to state_template
.
Did the state_template
resolve the issue?
Hi, at the end i converted the schedules to hass automations. I didnt want to change default behaviour of zigbee2mqtt.
The generic actor was unfortunately too complex for me to figure out.
Ah, I'm sure I can help you with that. I added the config you'd have to use with the generic actor to get the behavior of the switch actor to the docs. It should be easy to adapt to your needs now.
And I also updated this chapter to make it more clear why you might not want to use automations for scheduling. Maybe you want to read that as well.
Just ask if you've got further questions.
Thanks for your help. I found out the hard way why automations are a pain.. loads of code needed for basic actions. I do use the fact that ikea zigbee devices 'call home' every hour so if a switch did not switch effectively (or someone turned it on manually) it will still switch in the desired state.
I made the following test configuration, no errors are thrown but it is not working. I probably do something majorly wrong here.
schedy_achterdeur_test:
module: hass_apps_loader
class: SchedyApp
actor_type: generic
actor_templates:
default:
attributes:
- attribute: state
values:
"ON":
service: homeassistant.turn_on
"OFF":
service: homeassistant.turn_off
schedule_prepend:
schedule_append:
schedule_snippets:
rooms:
lamp_achterdeur_test:
friendly_name: lamp_achterdeur_test
allow_manual_changes: false
rescheduling_delay: 1
actors:
light.0xec1bbdfffea7b8a7_light:
schedule:
- value: "OFF"
start: "12:00"
end: "23:00"
- value: "ON"
watched_entities:
statistics:
Hm, what does "not working" mean? I can't see anything problematic in here...
What happens if you swap the "ON"
and "OFF"
and save the config? Does the light toggle then and what does Schedy say in the log then?
Ah, what makes no sense is disabling allow_manual_changes
and setting a rescheduling_delay
at the same time. Obviously, these two contradict eachother.
Thanks for your reply. I had this combination working in the switch actor, but i removed it since it makes indeed no sense. I swapped states around, and the state does not get detected. I also tried mapping to the group , doesnt work either. Currently i have this in the configuration:
schedy_achterdeur_test:
module: hass_apps_loader
class: SchedyApp
actor_type: generic
actor_templates:
default:
attributes:
- attribute: state
values:
"ON":
service: homeassistant.turn_on
"OFF":
service: homeassistant.turn_off
schedule_prepend:
schedule_append:
schedule_snippets:
rooms:
lamp_achterdeur_test:
friendly_name: lamp_achterdeur_test
allow_manual_changes: false
actors:
light.0xec1bbdfffea7b8a7_light:
schedule:
- value: "ON"
start: "08:00"
end: "23:00"
- value: "OFF"
watched_entities:
statistics:
This is the log:
2020-01-06 10:07:24.132481 INFO AppDaemon: Reading config
2020-01-06 10:07:24.174231 INFO AppDaemon: /config/appdaemon/apps/schedy.yaml added or modified
2020-01-06 10:07:24.174516 INFO AppDaemon: App 'schedy_achterdeur_test' changed
2020-01-06 10:07:24.175405 INFO AppDaemon: Terminating schedy_achterdeur_test
2020-01-06 10:07:24.175852 INFO AppDaemon: Initializing app schedy_achterdeur_test using class SchedyApp from module hass_apps_loader
2020-01-06 10:07:24.178625 INFO schedy_achterdeur_test: *** Welcome to schedy 0.7.0, running on AppDaemon 3.0.5.
2020-01-06 10:07:24.181060 INFO schedy_achterdeur_test: ***
2020-01-06 10:07:24.183455 INFO schedy_achterdeur_test: *** This is an app from the hass-apps package.
2020-01-06 10:07:24.185818 INFO schedy_achterdeur_test: *** DOCS: https://hass-apps.readthedocs.io/en/stable/
2020-01-06 10:07:24.188187 INFO schedy_achterdeur_test: ***
2020-01-06 10:07:24.190589 INFO schedy_achterdeur_test: *** You like this app, want to honor the effort put into
2020-01-06 10:07:24.192952 INFO schedy_achterdeur_test: *** it, ensure continuous development and support?
2020-01-06 10:07:24.195307 INFO schedy_achterdeur_test: *** Then please consider making a donation.
2020-01-06 10:07:24.197659 INFO schedy_achterdeur_test: *** DONATE: https://hass-apps.readthedocs.io/en/stable/#donations
2020-01-06 10:07:24.200048 INFO schedy_achterdeur_test: *** Thank you very much and enjoy schedy!
2020-01-06 10:07:24.202411 INFO schedy_achterdeur_test: ***
2020-01-06 10:07:24.207675 INFO schedy_achterdeur_test: --- Actor type is: 'generic'
2020-01-06 10:07:24.214440 INFO schedy_achterdeur_test: *** Initialization done.
this is the current state (as you can see, HAS makes the state lowercase)
Could you please post the state as YAML as shown in the HA dev tools? I'm blind and can't see what's on that image.
The log looks weird... it should at least report the current state upon initialization. Could you add debug: true
to the Schedy config and post the extended log this generates?
Thanks, current state in YAML:
state: 'OFF'
last_seen: '2020-01-06T09:03:44.689Z'
brightness: 140
linkquality: 81
friendly_name: achterdeur_lamp_light
supported_features: 41
debug: true does not work. below my configuration,same INFO output as posted before.
schedy_achterdeur_test:
module: hass_apps_loader
class: SchedyApp
debug: true
actor_type: generic
actor_templates:
default:
attributes:
- attribute: state
values:
"ON":
service: homeassistant.turn_on
"OFF":
service: homeassistant.turn_off
schedule_prepend:
schedule_append:
schedule_snippets:
rooms:
lamp_achterdeur_test:
friendly_name: lamp_achterdeur_test
allow_manual_changes: false
actors:
light.0xec1bbdfffea7b8a7_light:
schedule:
- value: "ON"
start: "08:00"
end: "23:00"
- value: "OFF"
watched_entities:
statistics:
log output . by the way the log record about schedy running on appdaemon 3.X is not true, i am running 4.1 , at least that is what the hass addon gui tells me.
Supervisor version: 193
-----------------------------------------------------------
Please, share the above information when looking for help
or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing...
Log level is set to INFO
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] appdaemon.sh: executing...
[12:17:31] INFO: Updating Hass.io API token in AppDaemon with the current one...
Looking in links: https://wheels.hass.io/alpine-3.10/armv7/
Collecting hass-apps
Downloading https://files.pythonhosted.org/packages/08/23/dd092b2144366057d0ec069ab6bc2c005c5daf546460b300a290f0ba4648/hass_apps-0.20191210.0-py3-none-any.whl (52kB)
Collecting observable>=1.0 (from hass-apps)
Downloading https://files.pythonhosted.org/packages/45/7c/b4b63f447378e8a0ebcd338d90f9389f57fb23253127425beacf0129edcb/observable-1.0.3-py2.py3-none-any.whl
Requirement already satisfied: appdaemon>=3.0 in /usr/lib/python3.7/site-packages (from hass-apps) (3.0.5)
Collecting cached-property>=1.5.1 (from hass-apps)
Downloading https://files.pythonhosted.org/packages/3b/86/85c1be2e8db9e13ef9a350aecd6dea292bd612fa288c2f40d035bb750ded/cached_property-1.5.1-py2.py3-none-any.whl
Requirement already satisfied: voluptuous>=0.11 in /usr/lib/python3.7/site-packages (from hass-apps) (0.11.7)
Requirement already satisfied: iso8601 in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (0.1.12)
Requirement already satisfied: bcrypt in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (3.1.7)
Requirement already satisfied: sseclient in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (0.0.24)
Requirement already satisfied: websocket-client in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (0.56.0)
Requirement already satisfied: aiohttp-jinja2==0.15.0 in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (0.15.0)
Requirement already satisfied: aiohttp==2.3.10 in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (2.3.10)
Requirement already satisfied: paho-mqtt in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (1.4.0)
Requirement already satisfied: requests>=2.6.0 in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (2.22.0)
Requirement already satisfied: yarl==1.1.0 in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (1.1.0)
Requirement already satisfied: Jinja2==2.10.1 in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (2.10.1)
Requirement already satisfied: feedparser in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (5.2.1)
Requirement already satisfied: daemonize in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (2.5.0)
Requirement already satisfied: astral in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (1.10.1)
Requirement already satisfied: pyyaml==5.1 in /usr/lib/python3.7/site-packages (from appdaemon>=3.0->hass-apps) (5.1)
Requirement already satisfied: cffi>=1.1 in /usr/lib/python3.7/site-packages (from bcrypt->appdaemon>=3.0->hass-apps) (1.12.3)
Requirement already satisfied: six>=1.4.1 in /usr/lib/python3.7/site-packages (from bcrypt->appdaemon>=3.0->hass-apps) (1.12.0)
Requirement already satisfied: chardet in /usr/lib/python3.7/site-packages (from aiohttp==2.3.10->appdaemon>=3.0->hass-apps) (3.0.4)
Requirement already satisfied: async-timeout>=1.2.0 in /usr/lib/python3.7/site-packages (from aiohttp==2.3.10->appdaemon>=3.0->hass-apps) (3.0.1)
Requirement already satisfied: idna-ssl>=1.0.0 in /usr/lib/python3.7/site-packages (from aiohttp==2.3.10->appdaemon>=3.0->hass-apps) (1.1.0)
Requirement already satisfied: multidict>=4.0.0 in /usr/lib/python3.7/site-packages (from aiohttp==2.3.10->appdaemon>=3.0->hass-apps) (4.5.2)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/lib/python3.7/site-packages (from requests>=2.6.0->appdaemon>=3.0->hass-apps) (1.25.4)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/lib/python3.7/site-packages (from requests>=2.6.0->appdaemon>=3.0->hass-apps) (2.8)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3.7/site-packages (from requests>=2.6.0->appdaemon>=3.0->hass-apps) (2019.9.11)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib/python3.7/site-packages (from Jinja2==2.10.1->appdaemon>=3.0->hass-apps) (1.1.1)
Requirement already satisfied: pytz in /usr/lib/python3.7/site-packages (from astral->appdaemon>=3.0->hass-apps) (2019.2)
Requirement already satisfied: pycparser in /usr/lib/python3.7/site-packages (from cffi>=1.1->bcrypt->appdaemon>=3.0->hass-apps) (2.19)
Installing collected packages: observable, cached-property, hass-apps
Successfully installed cached-property-1.5.1 hass-apps-0.20191210.0 observable-1.0.3
You are using pip version 19.0.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[cont-init.d] appdaemon.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[12:17:42] INFO: Starting AppDaemon...
2020-01-06 12:17:44.204579 INFO AppDaemon Version 3.0.5 starting
2020-01-06 12:17:44.204997 INFO Configuration read from: /config/appdaemon/appdaemon.yaml
2020-01-06 12:17:44.208154 INFO AppDaemon: Starting Apps
2020-01-06 12:17:44.228436 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2020-01-06 12:17:44.423896 INFO AppDaemon: HASS: HASS Plugin Initializing
2020-01-06 12:17:44.424623 INFO AppDaemon: HASS: HASS Plugin initialization complete
2020-01-06 12:17:44.425185 INFO Starting Dashboards
2020-01-06 12:17:44.436655 INFO API is disabled
2020-01-06 12:17:44.447196 INFO AppDaemon: HASS: Connected to Home Assistant 0.103.5
2020-01-06 12:17:44.533258 INFO AppDaemon: Got initial state from namespace default
2020-01-06 12:17:46.605157 INFO AppDaemon: Reading config
2020-01-06 12:17:46.640880 INFO AppDaemon: /config/appdaemon/apps/schedy.yaml added or modified
2020-01-06 12:17:46.641416 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified
2020-01-06 12:17:46.641883 INFO AppDaemon: /config/appdaemon/apps/schedy.yaml added or modified
2020-01-06 12:17:46.642334 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified
2020-01-06 12:17:46.642815 INFO AppDaemon: App 'schedy_achterdeur_test' added
2020-01-06 12:17:46.643287 INFO AppDaemon: App 'hello_world' added
2020-01-06 12:17:46.643974 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2020-01-06 12:17:46.648804 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hello.py
2020-01-06 12:17:46.670298 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hass_apps_loader.py
2020-01-06 12:17:46.733365 INFO AppDaemon: Initializing app schedy_achterdeur_test using class SchedyApp from module hass_apps_loader
2020-01-06 12:17:47.019289 INFO schedy_achterdeur_test: *** Welcome to schedy 0.7.0, running on AppDaemon 3.0.5.
2020-01-06 12:17:47.021980 INFO schedy_achterdeur_test: ***
2020-01-06 12:17:47.024438 INFO schedy_achterdeur_test: *** This is an app from the hass-apps package.
2020-01-06 12:17:47.026819 INFO schedy_achterdeur_test: *** DOCS: https://hass-apps.readthedocs.io/en/stable/
2020-01-06 12:17:47.029211 INFO schedy_achterdeur_test: ***
2020-01-06 12:17:47.031601 INFO schedy_achterdeur_test: *** You like this app, want to honor the effort put into
2020-01-06 12:17:47.033948 INFO schedy_achterdeur_test: *** it, ensure continuous development and support?
2020-01-06 12:17:47.036288 INFO schedy_achterdeur_test: *** Then please consider making a donation.
2020-01-06 12:17:47.038679 INFO schedy_achterdeur_test: *** DONATE: https://hass-apps.readthedocs.io/en/stable/#donations
2020-01-06 12:17:47.041105 INFO schedy_achterdeur_test: *** Thank you very much and enjoy schedy!
2020-01-06 12:17:47.043485 INFO schedy_achterdeur_test: ***
2020-01-06 12:17:47.045658 INFO schedy_achterdeur_test: --- Validating the app's configuration.
2020-01-06 12:17:47.049790 INFO schedy_achterdeur_test: --- Actor type is: 'generic'
2020-01-06 12:17:47.052366 INFO schedy_achterdeur_test: --- Listening for schedy_reevaluate event.
2020-01-06 12:17:47.055361 INFO schedy_achterdeur_test: --- Listening for schedy_set_value event.
2020-01-06 12:17:47.058251 INFO schedy_achterdeur_test: *** Initialization done.
2020-01-06 12:17:47.058591 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2020-01-06 12:17:47.061336 INFO hello_world: Hello from AppDaemon
2020-01-06 12:17:47.063873 INFO hello_world: You are now ready to run Apps!
2020-01-06 12:17:47.065040 INFO AppDaemon: App initialization complete
2020-01-06 12:19:06.507849 INFO AppDaemon: Reading config
2020-01-06 12:19:06.545456 INFO AppDaemon: /config/appdaemon/apps/schedy.yaml added or modified
2020-01-06 12:19:27.675479 INFO AppDaemon: Reading config
2020-01-06 12:19:27.714308 INFO AppDaemon: /config/appdaemon/apps/schedy.yaml added or modified
Your addon version may be 4.1, however the version of included AppDaemon is 3.0.5, these two are expected to be different.
The debug setting indeed worked, since it now outputs that it listens for the schedy_* events, which is a debug only log message.
However, it completely ignores the room you defined in your config... I'll look at your config again.
Ah, got it! You probably were hit by some auto indentation of your editor.
Everything from schedule_prepend:
onwards is indented one level too much and thus is counted as another actor template. The statistics:
is actually indented two levels too much.
Ah, got it! You probably were hit by some auto indentation of your editor.
Everything from
schedule_prepend:
onwards is indented one level too much and thus is counted as another actor template. Thestatistics:
is actually indented two levels too much.
This was indeed the issue and its functioning now ! Thanks very much. Will ease my life a lot. Now going to work on sunset and sunrise, allready found a config for that in a thread.
For the record, below the test config:
schedy_achterdeur_test:
module: hass_apps_loader
class: SchedyApp
debug: true
actor_type: generic
actor_templates:
default:
attributes:
- attribute: state
values:
"ON":
service: homeassistant.turn_on
"OFF":
service: homeassistant.turn_off
schedule_prepend:
schedule_append:
schedule_snippets:
rooms:
lamp_achterdeur_test:
friendly_name: lamp_achterdeur_test
allow_manual_changes: false
actors:
light.0xec1bbdfffea7b8a7_light:
schedule:
- value: "OFF"
start: "08:00"
end: "23:00"
- value: "ON"
watched_entities:
statistics:
Great! Wish you good luck with further config.
I'm currently working on the generic2
actor. When that's ready, switch
will also use it under the hood and you can then simply use switch
with no further configuration. Will be in next release.
There seems to be an issue or combination problem between my ikea devices, HAS and schedy. The schedy Switch generic actor expects values "off" and "on". However the ikea switches (zigbee2mqtt) push those values uppercase ("OFF" and "ON") HAS handles this fine.
In schedy i get the below error on state change of the device:
2020-01-01 23:37:37.019442 ERROR schedy_test: !!! [R:test_fulltime] [A:switch.0x000d6ffffeaa2589_switch] State 'ON' for slot 0 is not known by this generic actor, ignoring state change.
Strangly it does switch sometimes, only ON so it seems.
I cannot set the values to uppercase in the config because it won't accept this (for the same reason).
Workaround i currently have is to give each device its own HASS group and use the group in schedy. Groups state are lower case by default (but unreliable with multiple devices in it because the state is not consistent with all devices - off especially)