Nickduino / Pi-Somfy

A script to open and close your Somfy (and SIMU) blinds with a Raspberry Pi and an RF emitter.
Other
437 stars 109 forks source link

weather integration for awnings #32

Closed lfliess closed 5 years ago

lfliess commented 5 years ago

I'm starting work on a weather module - integrates with Yahoo weather, and allowing user to register for closing the awning in case of rain/strong wind (wind speed configurable). I will add this to work together with the CLI shcedule, but would need help to integrate it into the GUI.

Nickduino commented 5 years ago

We already have some weather implementation in the pipeline with Michael. It's likely it will do what you expect but the development is pretty slow, sorry for that.

lfliess commented 5 years ago

in that case, I'd like to offer my help since I already have some code done. @MichaelB2018 - do you want to sync on this?

MichaelB2018 commented 5 years ago

sure - have not had much time to look into this recently, but feel free to merge it.

lfliess commented 5 years ago

Is there any partial code you want me to look at? or just go ahead with what I started and we can see where we want to take it from there?

MichaelB2018 commented 5 years ago

no partial code, I'm afraid. The only thing 2 things I was thinking off are: 1.) use https://github.com/csparpa/pyowm 2.) add a timeType of "weather" (currently it has clock & astro) in the scheduler

Also a small hint.. watch out of oscillating values in OpenWeatherMap... eg. the below is a graph of wind speeds... If I had set a trigger to for the awning to lower/raise at a wind speed of 6 m/s, my awning would have been non-stop busy today: image So maybe add some threshold or similar.

Nickduino commented 5 years ago

In that case, I think the easiest thing is to use hysteresis. You' close the awning if the wind exceeds 6 m/s and open it if it drops below 2 (or don't open it at all)

MichaelB2018 commented 5 years ago

which you can do easily with 2 different "schedules", so you don't even need to cater for hysteresis in the code.

Nickduino commented 5 years ago

Absolutely

lfliess commented 5 years ago
  1. I started with yahoo weather, but I can use OWM just as well
  2. not really a scheduler as that isn't safe - strong winds can start suddenly. I want to act according to live weather. I can just poll the weather every few minutes, and if the wind is high, or if it rains, just close the awning.
  3. I have the wind part done, but having some trouble with rain as both Yahoo and OWM only tell you if it's raining using strings ("sunny", "partly cloudy", "raining", etc...). but there are so many different options for raining that for this I might go with a scheduler - decide on a daily basis to open or not (if it's not sunny or even raining - no need to open awning at all)
MichaelB2018 commented 5 years ago
  1. & 2.) perfect, no worries 3.) Maybe even languages might be a concern as well for some folks. But I like the idea of a scheduler for certain weather and immediate events. We were talking once about adding conditions to existing time or astro related events. Maybe add something in the Event class.
lfliess commented 5 years ago

I gave up on this. will use the new MQTT support to have Home Assistant do this. it already has good weather integration that's being maintained. I actually think this is a better solution to everyone. you can even run hass.io on the same RPi that you use this for. then you don't need MQTT, you can just call the command line commands....

an interesting project might be to implement Pi-Somfy as a HA plug-in

MichaelB2018 commented 5 years ago

Make sure you use MQTT discovery for Home Assistant (https://www.home-assistant.io/docs/mqtt/discovery/) which makes it easier. Probably need to do a bit more documentation when I get to it. But let me know if you get it to work. Keen to get some more testers in case of any issues

lfliess commented 5 years ago

I tried it yesterday with my newly installed hass.io with Mosquitto I installed it in a docker on the same rpi

but I'm getting trouble with discovery. from the logs so far it seems your code does the job and sends a message that looks like a legitimate discovery message, but hass.io doesn't discover a new device.

I also tried manually adding the topics but I think I now have the problem where the MQTT broker starts up too late and hass.io gives up on it on startup.

will try to resolve my issues and tell you if it works for me

lfliess commented 5 years ago

I didn't configure my broker correctly. now it works. the cover was discovered and I'm able to control it correctly through HA

great job! I can now use the openweathermap hass.io integration to create any automation I'd like. this is just what I needed

MichaelB2018 commented 5 years ago

glad t worked. Given that it;s all fresh in your mind, do you want to help with documenting how to set it up? (as you can see, documentation is never my favorite part).

lfliess commented 5 years ago

Sure I did just what the documentation said and it worked (-m flag) The trouble I had was setting up Hass.io with mqtt I can put in paragraph about it...

On Wed, Oct 30, 2019, 00:16 MichaelB2018 notifications@github.com wrote:

glad t worked. Given that it;s all fresh in your mind, do you want to help with documenting how to set it up? (as you can see, documentation is never my favorite part).

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Nickduino/Pi-Somfy/issues/32?email_source=notifications&email_token=AANJPR7WGP2YFT5ZXXA2F3LQRCY4XA5CNFSM4HHNVZ52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECSIRCY#issuecomment-547653771, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANJPR7BFK3LIU6UKKUGQDTQRCY4XANCNFSM4HHNVZ5Q .

Nickduino commented 5 years ago

The trouble I had was setting up Hass.io with mqtt I can put in paragraph about it...

Definitely.