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

Adding system scripts that are automatically executed when idle level is changed #531

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

marsman7
Copy link
Contributor

Adding additional system scripts that are automatically executed when the idle level is changed.

  • idle_off.cmd
  • idle_short.cmd
  • idle_long.cmd

In example this scripts can use to easy control the backlight or change page

  • idle_off.cmd
backlight {"state": true, "brightness": 255}
moodlight {"state": false}
  • idle_short.cmd
backlight {"state": "on", "brightness": 50}
  • idle_long.cmd
backlight {"state": false, "brightness": 5}
moodlight {"state": true, "color":"green"}

… the idle level is changed.

* idle_off.cmd
* idle_short.cmd
* idle_long.cmd

In example this scripts can use to easy control the backlight or change page

* idle_off.cmd

```
backlight {"state": true, "brightness": 255}
moodlight {"state": false}
```

* idle_short.cmd

```
backlight {"state": "on", "brightness": 50}
```

* idle_long.cmd

```
backlight {"state": false, "brightness": 5}
moodlight {"state": true, "color":"green"}
```
@fvanroie fvanroie merged commit 71237c2 into HASwitchPlate:master Aug 25, 2023
@fvanroie
Copy link
Collaborator

Thanks. Please also update CHANGELOG.md and the docs repo.

@htvekov
Copy link

htvekov commented Aug 30, 2023

I like the idea with individual scripts for different idle status levels 👍
Will these scripts not conflict with the existing HA custom component code that already handles idle status ?

@marsman7
Copy link
Contributor Author

The scripts are for every user, even those who don't use HA and they work even if Wifi is disturbed. If you use HA and the scripts, you have to make sure that they do not contradict each other.

@nagyrobi
Copy link
Collaborator

How?

@marsman7
Copy link
Contributor Author

marsman7 commented Aug 30, 2023

I don't use HA, I don't know but you can certainly customize the HA configuration to your liking.

https://openhasp.haswitchplate.com/0.6/integrations/home-assistant/sampl_autom/

In the link above you can see the "action" section in the HA script. Change it.

@htvekov
Copy link

htvekov commented Aug 30, 2023

I don't use HA, I don't know but you can certainly customize the HA configuration to your liking.

https://openhasp.haswitchplate.com/0.6/integrations/home-assistant/sampl_autom/

In the link above you can see the "action" section in the HA script. Change it.

The custom component responds with a backlight state and brightness setting whenever openHASP issues an idle_xx mesage.
So changing the idle period in the openHASP device won't solve this.

It's actually an ongoing issue which is not resolved yet. Using the HA custom component it's impossible to configure whether or not you want it to respond or not on some/all idle messages. The idle_brightness and brightness values are dynamic, but the responses are hardcoded. It's all or nothing...

I had to hack the component doing my openHASP proximity sensor custom code.
Another approach could be to stop openHASP from issuing some/all idle commands by setting idle time to 0

image

@fvanroie
Copy link
Collaborator

I don't see a problem unless you configure contradicting brightness settings locally and in HA...
Either set the brightness locally, or use HA, or both and make sure they match.

@htvekov
Copy link

htvekov commented Aug 30, 2023

Brightness values can be altered in HA (manually or by automation).
So it would be a challenge to ensure identical settings - One being static where the other is dynamic 😉

IMO backlight idle state/brightness should ideally be configurable and fully controlled locally on the device.
It's not a big issue for me, as I'm aware of this and know how to circumvent it.

@fvanroie
Copy link
Collaborator

IMO backlight idle state/brightness should ideally be configurable and fully controlled locally on the device.

This PR implements that, and more since you can use other commends too besides brightness.

@marsman7
Copy link
Contributor Author

The idle scripts are not only to control the backlight. In example you can use it go to a default page or control the moodlight.

@htvekov
Copy link

htvekov commented Sep 3, 2023

IMO backlight idle state/brightness should ideally be configurable and fully controlled locally on the device.

This PR implements that, and more since you can use other commends too besides brightness.

Yep, full local control. But on the other hand you'll then loose the possibility to dynamically control the brightness values / BL states for all three idle states.

The main issue here is that it's impossible to use the CC and at the same time control the brightness with the new scripts.
You simply can't turn off the idle command responses completely in the CC. And if you 'kill' the idle states from being issued from the device (setting the idle settings to zero in the device), then you'll also loose the possibility to act on the idle state change e.g. via automations in HA.
Idle_short brightness settings has an on/off flag and a slider value setting. But the CC doesn't respect the brightness level on/off flag (most likely a bug in the CC). Removing the flag, saving and reloading the CC will set flag again.

image

idle_long as well as idle_off has no user interface settings at all in the CC. idle_long will change BL state to zero and idle_off will set brightness to whatever value you've configured for the BL brightness in HA. Actually nothing wrong with that, as the values are fully dynamic. But the responses are not. The CC will fire these responses, whether you like it or not...

That's why I wrote as I did earlier. From a Home Assistant user perspective it simply would be much easier if the BL state & brightness level for the three idle states were controlled completely by openHASP core in the device. The timing config is already there. We just need the brightness/states variables internally, the ability to change these via commands and a few lines of code to change the state/levels accordingly.

If I had the skills I would definitely have made a PR for this 😉

@nagyrobi
Copy link
Collaborator

nagyrobi commented Sep 3, 2023

@dgomes

@htvekov
Copy link

htvekov commented Sep 3, 2023

The idle scripts are not only to control the backlight. In example you can use it go to a default page or control the moodlight.

I'm aware of that 😉
It's really a great feature with these local scripts where all openHASP commands can be fired. There will most likely be many use cases where this ability will come in handy 👍😎

The BL control & brightness just came to my mind as the current solution in the CC for HA users is somewhat flawed

@kinosang
Copy link
Contributor

scripts not fires when idle state changing.

#[00:29:31.895][65524/75644 13][56344/56344  0] MQTT: Disconnected
#[00:29:36.557][65524/77228 15][56344/56344  0] HASP: First touch Disabled
**should run idle_off.cmd**
#[00:29:36.572][65524/75644 13][56344/56344  0] MQTT: Not connected ??? backlight => {"state":"on","brightness":3}
#[00:29:36.584][65524/77228 15][56344/56344  0] MQTT: Not connected ??? idle => off
**should run idle_short.cmd**
#[00:29:42.037][65524/77064 14][56344/56344  0] MQTT: Not connected ??? idle => short
#[00:29:43.906][65524/77228 15][56344/56344  0] MQTT: Transport error
#[00:29:43.917][65524/75644 13][56344/56344  0] MQTT: Disconnected

But run idle short command through Telnet/Serial will fire the script.

#idle short
[00:29:19.249][65524/77064 14][56344/56344  0] MSGR: idle=short
#idle shor[00:29:19.272][65524/75480 13][56344/56344  0] MSGR: Loading L:/idle_short.cmd
#idle shor[00:29:19.302][61428/70976 13][56344/56344  0] MSGR: backlight={"state": false, "brightness": 3}
#idle shor[00:29:19.313][59380/69392 14][56344/56344  0] HASP: First touch Enabled
#idle shor[00:29:19.328][61428/70976 13][56344/56344  0] MQTT: Not connected ??? backlight => {"state":"off","brightness":3}
#idle shor[00:29:19.341][59380/69392 14][56344/56344  0] MSGR: moodlight={"state": true, "color":"green"}
#idle shor[00:29:19.359][61428/70976 13][56344/56344  0] MQTT: Not connected ??? moodlight => {"state":"on","brightness":255,"color":"#008000","r":0,"g":128,"b":0}
#idle shor[00:29:19.371][59380/74408 20][56344/56344  0] MSGR: Loaded L:/idle_short.cmd
#idle shor[00:29:19.383][65524/77064 14][56344/56344  0] MQTT: Not connected ??? idle => short
#[00:29:19.862][65524/77228 15][56344/56344  0] MQTT: Transport error
#[00:29:19.873][65524/75644 13][56344/56344  0] MQTT: Disconnected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants