11125
(Тони Станојоски)
February 1, 2022, 11:27pm
1
Hello all,
I have this code in my sensors.yaml file and I keep receiving errors. Can you please help?
The code should get the response in the TCP platform, and then in the template, it should return 2 values.
- platform: tcp
name: 4heat_response
host: 192.168.0.14
port: 80
timeout: 5
payload: '["SEL","0"]'
unit_of_measurement: "°C"
- platform: template
sensors:
Stove_temp0:
entity_id: sensor.4heat_water_temp
name: "4heat Water Temperature"
value_template: "{{ int(states('4heat_response')[states('4heat_response').find('J30017')+6:states('4heat_response').find('J30017')+18])) }}"
Stove_Temp1:
entity_id: sensor.4heat_boiler_set_temp
name: "4heat Boiler Target Temperature"
value_template: "{{ int(states('4heat_response')[states('4heat_response').find('B20180')+6:states('4heat_response').find('B20180')+18])) }}"
The error I receive when i validate the configuration is:
Invalid config for [sensor.template]: invalid slug Stove_temp0 (try stove_temp0) for dictionary value @ data[‘sensors’]. Got OrderedDict([(‘Stove_temp0’, OrderedDict([(‘entity_id’, ‘sensor.4heat_water_temp’), (‘name’, ‘4heat Water Temperature’), (‘value_template’, “{{ int(states(‘4heat_response’)[states(‘4heat_response’).find(‘J30017’)+6:states(‘4heat_response’).find(‘J30017’)+18])) }}”)])), (‘Stove_Temp1’, OrderedDict([(‘entity_id’, ‘sensor.4heat_boiler_set_temp’), (‘name’, ‘4heat Boiler Target Temperature’), (‘value_template’, "{{ int(states(‘4heat_response’)[states(‘4heat_response’).find(‘B20180’)+6:states('4hea… (See ?, line ?).
tom_l
February 1, 2022, 11:29pm
2
You cant use capital letters here:
- platform: template
sensors:
Stove_temp0:
Do this instead:
- platform: template
sensors:
stove_temp0:
Same for Stove_temp1
1 Like
123
(Taras)
February 1, 2022, 11:43pm
3
In addition, be advised that Template Sensors no longer use the entity_id
option (it was deprecated many versions ago).
1 Like
11125
(Тони Станојоски)
February 1, 2022, 11:46pm
4
I did change the case of the letters and I also i changed the name: to friendly_name:
now i have this code
- platform: template
sensors:
stove_temp0:
friendly_name: "4heat Boiler Water Temperature"
# entity_id: sensor.4heat_water_temp
value_template: "{{ int(states('4heat_response')[states('4heat_response').find('J30017')+6:states('4heat_response').find('J30017')+18])) }}"
stove_temp1:
# entity_id: sensor.4heat_boiler_set_temp
friendly_name: "4heat Boiler SET Temperature"
value_template: "{{ int(states('4heat_response')[states('4heat_response').find('B20180')+6:states('4heat_response').find('B20180')+18])) }}"
and this error:
Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: unexpected ‘)’) for dictionary value @ data[‘sensors’][‘stove_temp0’][‘value_template’]. Got “{{ int(states(‘4heat_response’)[states(‘4heat_response’).find(‘J30017’)+6:states(‘4heat_response’).find(‘J30017’)+18])) }}”
invalid template (TemplateSyntaxError: unexpected ‘)’) for dictionary value @ data[‘sensors’][‘stove_temp1’][‘value_template’]. Got “{{ int(states(‘4heat_response’)[states(‘4heat_response’).find(‘B20180’)+6:states(‘4heat_response’).find(‘B20180’)+18])) }}”. (See ?, line ?).
123
(Taras)
February 1, 2022, 11:49pm
5
This is invalid:
states('4heat_response')
You have to supply the states()
function with a proper entity_id.
For example:
states('sensor.4heat_response')
For more information, refer to this section in the documentation .
Can you share an example of the state
value of sensor.4heat_response
? I am curious to know what kind of data that template is processing.
11125
(Тони Станојоски)
February 1, 2022, 11:51pm
6
One of the responses from the controller is this one:
[“SEL”,“11”,“J30001000000000000”,“J30002000000000000”,“J30005000000000021”,“J300 06000000000000”,“J30011000000000110”,“J30012000000000000”,“J30017000000000022”," J30020000000000000",“B20180000000000066”,“B20005000000000030”,“B20006000000000080”]
11125
(Тони Станојоски)
February 1, 2022, 11:52pm
7
this is the topic where i share all the data
Hello, I purchased a Tiemme wifi stove controller for my Milkuz Pellet Stove . It connects to the wifi router and then to https://wifi4heat.azurewebsites.net/ [IP: 51.140.152.154]
There is only Mobile App 4Heat to send commands to the controller.
Is there anyone working on this? Is anyone interested?
The bummer is that I can’t seem to find any contact with the company. They say they support the controller for integration with google home and integration with Alexa. I tried to add it to Google …
123
(Taras)
February 2, 2022, 12:00am
8
As an experiment, copy-paste this into the Template Editor and see what it reports:
{{ (states('sensor.4heat_response') | from_json)[8] }}
1 Like
11125
(Тони Станојоски)
February 2, 2022, 12:06am
9
it is working ! I found one more extra ‘)’ at the end
Thanks a lot @123 and @tom_l
This is my first contribution to the community. Do you think it takes a lot of time to make it into custom integration since I already practically have the whole communication on the controller?
123
(Taras)
February 2, 2022, 12:10am
10
I hope you realize that an entity’s state
value can only contain a string that’s 255 characters or less. The payload example you provided is 246 characters long. If that’s the longest it ever gets then you’re fine. If it ever exceeds 255, the excess is discarded.
11125
(Тони Станојоски)
February 2, 2022, 12:16am
11
I think it is fine, coz the controller seems to send all the time same string length. He is using the zeros as free space. I noticed that when the exhaust temperature was 140 degrees.