Skip to content

Commit

Permalink
small fixes and add netatmo support
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewOnTour committed Apr 18, 2024
1 parent a883321 commit abbc27a
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ Then, just give Home Assistant a quick restart, and you're good to go.

Head over to Settings -> Devices and Services -> Click on Add Integration (select Blinds Control) to integrate your blinds into the system.

Name your blinds, select the controlling entities, specify roll-up and roll-down times in seconds, and if you need it, set tilt times (or leave them at 0 if you don't want tilting support).
Name your blinds, select the controlling entities, specify roll-up and roll-down times in seconds, and if you need it, set tilt times (or leave them at 0 if you don't want to tilt support).

You can also tweak existing configurations to suit your preferences (just reload the edited entries).

## Automations
During the setup process, you have the option to configure various automated tasks. These features are currently in an EXPERIMENTAL phase and are being developed as part of my bachelor's thesis, so please refrain from extensive experimentation with these automations.
During the setup process, you have the option to configure various automated tasks. These features are currently in an EXPERIMENTAL phase and are being developed as part of my bachelor's thesis, so please refrain from extensive experimentation with this automation.

Examples include scheduling specific times for actions such as raising or lowering blinds, automating the opening and closing of blinds based on sunrise and sunset times, or automatically lowering blinds when a particular entity is activated during the night. Additionally, there are weather protection measures available, such as responding to strong winds using the [WMO Code](https://www.nodc.noaa.gov/archive/arc0021/0002199/1.1/data/0-data/HTML/WMO-CODE/WMO4677.HTM) and utilizing the [Open Meteo API](https://open-meteo.com/). For those utilizing interlock relays, there's the possibility to trigger a stop command at the end of a travel.
Examples include scheduling specific times for actions such as raising or lowering blinds, automating the opening and closing of blinds based on sunrise and sunset times, or automatically lowering blinds when a particular entity is activated during the night. Additionally, there are weather protection measures available, such as responding to strong winds using the [WMO Code](https://www.nodc.noaa.gov/archive/arc0021/0002199/1.1/data/0-data/HTML/WMO-CODE/WMO4677.HTM) and utilizing the [Open Meteo API](https://open-meteo.com/) or perhaps you would like to use Netatmo, that also works. For those utilizing interlock relays, there's the possibility of triggering a stop command at the end of travel.

## Need Help?

Expand Down
11 changes: 11 additions & 0 deletions custom_components/blinds_controller/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ async def async_step_user(self, user_input=None):
vol.Optional("wind_speed", default=30): vol.All(vol.Coerce(float)),
vol.Optional("wmo_code", default=80): vol.All(vol.Coerce(int)),

vol.Required("netamo_enable", default=False): bool,
vol.Required("netamo_speed_entity", default=None): vol.In(self._get_entity_ids()),
vol.Optional("netamo_speed", default=30): vol.All(vol.Coerce(float)),
vol.Required("netamo_gust_entity", default=None): vol.In(self._get_entity_ids()),
vol.Optional("netamo_gust", default=40): vol.All(vol.Coerce(float)),


vol.Required("send_stop_at_end", default=True): bool
}
Expand Down Expand Up @@ -102,6 +108,11 @@ async def async_step_init(self, user_input=None):
vol.Required("protect_the_blinds", default=self.config_entry.data.get("protect_the_blinds")): bool,
vol.Optional("wind_speed", default=self.config_entry.data.get("wind_speed")): vol.All(vol.Coerce(float)),
vol.Optional("wmo_code", default=self.config_entry.data.get("wmo_code")): vol.All(vol.Coerce(int)),
vol.Required("netamo_enable", default=self.config_entry.data.get("netamo_enable")): bool,
vol.Required("netamo_speed_entity", default=self.config_entry.data.get("netamo_speed_entity")): vol.In(self._get_entity_ids()),
vol.Optional("netamo_speed", default=self.config_entry.data.get("netamo_speed")): vol.All(vol.Coerce(float)),
vol.Required("netamo_gust_entity", default=self.config_entry.data.get("netamo_gust_entity")): vol.In(self._get_entity_ids()),
vol.Optional("netamo_gust", default=self.config_entry.data.get("netamo_gust")): vol.All(vol.Coerce(float)),
vol.Required("send_stop_at_end", default=self.config_entry.data.get("send_stop_at_end")): bool,
}
),
Expand Down
23 changes: 22 additions & 1 deletion custom_components/blinds_controller/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry, name, device_id):
self._protect_the_blinds = entry.data["protect_the_blinds"]
self._set_wind_speed = entry.data["wind_speed"]
self._wmo_code = entry.data["wmo_code"]
self._netamo_enable = entry.data["netamo_enable"]
self._netamo_speed_entity = entry.data["netamo_speed_entity"]
self._wind_speed = self.hass.states.get(self._netamo_speed_entity).state
self._netamo_speed = entry.data["netamo_speed"]
self._netamo_gust_entity = entry.data["netamo_gust_entity"]
self._gust_speed = self.hass.states.get(self._netamo_gust_entity).state
self._netamo_gust = entry.data["netamo_gust"]
self._send_stop_at_end = entry.data["send_stop_at_end"]

self._sun_next_sunrise = self.hass.states.get("sensor.sun_next_dawn").state
Expand Down Expand Up @@ -364,7 +371,7 @@ def auto_updater_hook(self, now):

async def add_ons(self, now):
# Adjust the current time by adding one hour
corrected_time = now + timedelta(hours=1) # Edit the time if needed to correct the time zone
corrected_time = now + timedelta(hours=0) # Edit the time if needed to correct the time zone

# Format the corrected time to display only HH:MM
formatted_time = corrected_time.strftime("%H:%M")
Expand Down Expand Up @@ -438,6 +445,20 @@ async def add_ons(self, now):
if not (formatted_time > formatted_time_sunset or formatted_time < formatted_time_sunrise) and self.tilt_calc.current_position() < 100:
await self.async_open_cover_tilt()

if self._netamo_enable and not self.travel_calc.is_traveling():
_LOGGER.info("wind: %s", self._wind_speed)
_LOGGER.info("wind: %s", self._netamo_speed)
_LOGGER.info("gust: %s", self._gust_speed)
_LOGGER.info("gust: %s", self._netamo_gust)
self._wind_speed = float(self._wind_speed)
self._netamo_speed = float(self._netamo_speed)
self._gust_speed = float(self._gust_speed)
self._netamo_gust = float(self._netamo_gust)
if self._wind_speed > self._netamo_speed and self.travel_calc.current_position() < 100:
await self.async_open_cover()
elif self._gust_speed > self._netamo_gust and self.travel_calc.current_position() < 100:
await self.async_open_cover()

_LOGGER.info("self._protect_the_blinds: %s", self._protect_the_blinds)
if self._protect_the_blinds and not self.travel_calc.is_traveling():
self._weather_check_counter += 1
Expand Down
4 changes: 2 additions & 2 deletions custom_components/blinds_controller/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set_known_position:
position:
name: Entity ID
description: The position to set
example: 50
example: 100

set_known_tilt_position:
description: Set the known tilt position of the blinds
Expand All @@ -20,4 +20,4 @@ set_known_tilt_position:
position:
name: Entity ID
description: The tilt position to set
example: 50
example: 100
14 changes: 12 additions & 2 deletions custom_components/blinds_controller/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
"protect_the_blinds": "Protect the blinds from the strong wind and rain",
"wind_speed": "Wind speed in km/h (if current above blinds will close)",
"wmo_code": "WMO code for the location (if current above blinds will close)",
"send_stop_at_end": "Send stop command at the end (interlock relay)"
"send_stop_at_end": "Send stop command at the end (interlock relay)",
"netamo_enable": "If netamo configured enable this to protect the blinds from the strong wind",
"netamo_speed_entity": "Wind speed entity from netamo",
"netamo_speed": "Wind speed in km/h (if current above blinds will close)",
"netamo_gust_entity": "Wind gust entity from netamo",
"netamo_gust": "Wind gust in km/h (if current above blinds will close)"
}
}
}
Expand Down Expand Up @@ -57,7 +62,12 @@
"protect_the_blinds": "Protect the blinds from the strong wind and rain",
"wind_speed": "Wind speed in km/h (if current above blinds will close)",
"wmo_code": "WMO code for the location (if current above blinds will close)",
"send_stop_at_end": "Send stop command at the end (interlock relay)"
"send_stop_at_end": "Send stop command at the end (interlock relay)",
"netamo_enable": "If netamo configured enable this to protect the blinds from the strong wind",
"netamo_speed_entity": "Wind speed entity from netamo",
"netamo_speed": "Wind speed in km/h (if current above blinds will close)",
"netamo_gust_entity": "Wind gust entity from netamo",
"netamo_gust": "Wind gust in km/h (if current above blinds will close)"
}
}
}
Expand Down
14 changes: 12 additions & 2 deletions custom_components/blinds_controller/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
"protect_the_blinds": "Protect the blinds from the strong wind and rain",
"wind_speed": "Wind speed in km/h (if current above blinds will close)",
"wmo_code": "WMO code for the location (if current above blinds will close)",
"send_stop_at_end": "Send stop command at the end (interlock relay)"
"send_stop_at_end": "Send stop command at the end (interlock relay)",
"netamo_enable": "If netamo configured enable this to protect the blinds from the strong wind",
"netamo_speed_entity": "Wind speed entity from netamo",
"netamo_speed": "Wind speed in km/h (if current above blinds will close)",
"netamo_gust_entity": "Wind gust entity from netamo",
"netamo_gust": "Wind gust in km/h (if current above blinds will close)"
}
}
}
Expand Down Expand Up @@ -57,7 +62,12 @@
"protect_the_blinds": "Protect the blinds from the strong wind and rain",
"wind_speed": "Wind speed in km/h (if current above blinds will close)",
"wmo_code": "WMO code for the location (if current above blinds will close)",
"send_stop_at_end": "Send stop command at the end (interlock relay)"
"send_stop_at_end": "Send stop command at the end (interlock relay)",
"netamo_enable": "If netamo configured enable this to protect the blinds from the strong wind",
"netamo_speed_entity": "Wind speed entity from netamo",
"netamo_speed": "Wind speed in km/h (if current above blinds will close)",
"netamo_gust_entity": "Wind gust entity from netamo",
"netamo_gust": "Wind gust in km/h (if current above blinds will close)"
}
}
}
Expand Down

0 comments on commit abbc27a

Please sign in to comment.