Cześć.
Od kilku dni uczę się HA i nie mogę poradzić sobie z podzieleniem zmiennej przez liczbę.
Zczytuję zmienną po modbus tcp, np 175 i te wartości umiem już wyświetlić na dashboardzie itp.
Jak tą zmienną podzielić przez 10, aby wyświetlić 17.5 ?
Na logikę rozumiem, że muszę wartość odczytywaną z modbus zapisać pod nową nazwą zmiennej która będzie liczbą z przecinkiem. Wybaczcie amatorskie pytanie, ale nie rozumiem jeszcze jak HA odczytuje kod.
Ta ostatnia część kodu po “template” to informacje z internetu. Myślałem, że po takiej operacji pojawi się nowa zmienna “temp10” która będzie zmienną “modbus_pogodynka” / 10 +_1 miejsce po przecinku
poniżej mój kod:
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
modbus:
- name: "logoo"
type: tcp
host: 192.168.1.3
port: 503
delay: 0
timeout: 1
switches:
- name: Switch_00
slave: 255
address: 0 # VB0.0
write_type: coil
command_on: 1
command_off: 0
verify:
sensors:
- name: modbus_temp_varaaja_T1 #Inveo Hero ModBus
slave: 255
unit_of_measurement: °C
state_class: measurement
device_class: temperature
scan_interval: 1
address: 1 # VW2
input_type: holding
- name: modbus_pogodynka #Inveo Hero ModBus
slave: 255
unit_of_measurement: °C
state_class: measurement
device_class: temperature
scan_interval: 15
address: 2 # VW4
input_type: holding
template:
- sensor:
- name: "temp10"
unit_of_measurement: °C
value_template: "{{ (states('sensor.modbus_pogodynka') | int / 10 | round(1)) }}"