Skip to content

Instantly share code, notes, and snippets.

@boozeman
Last active April 23, 2023 18:40
Show Gist options
  • Save boozeman/714659a0c4007525c94811a38045d050 to your computer and use it in GitHub Desktop.
Save boozeman/714659a0c4007525c94811a38045d050 to your computer and use it in GitHub Desktop.
Home assistant automation Action to control DS3502 Digital Potentiometer with somekind of Map-Float-Function. There's 3 Helpers, Fan Min Temp, Max Temp and Fan max (0-127)
service: mqtt.publish
data:
topic: cmnd/Greenhouse1/wiper1
qos: "0"
retain: true
payload_template: >-
{% set greenhouse_temp = states('sensor.greenhouse1_ec_fan_control_temperature') |float %}
{% if greenhouse_temp <24.0 %} 0
{% else %}
{% set temp_min = states('input_number.ec_fan_temp_min') |float %}
{% set temp_max = states('input_number.ec_fan_temp_max') |float %}
{% set ec_min = 13 |int %}
{% set ec_max = states('input_number.ec_fan_max') |int %}
{% if greenhouse_temp < temp_max %}
{% set Wiper = ((temp_max - greenhouse_temp) / (temp_max - temp_min)) * (ec_min - ec_max) + ec_max %}
{{ Wiper |int }}
{%else %}
125
{% endif %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment