Possible to delay or stagger Command line sensors?

Thank you for taking the time to read my question.

I can communicate with my heating unit through http which I can get to via a curl command. In order to have some data readout (and automatizations) I want to have multiple command line sensors working.

However, when attempting this, I encounter an issue: only one sensor works, the rest return the error message: “Wait at least 2500ms during requests.”
To me this seems as if the heating unit does not like getting 3 commands almost simultaneously.

There seems to be a simple solution: release the curl commands a few seconds apart. I have searched far and wide on how to do this, but to no avail.

Can you delay a command line sensor? Might there be a work around I’m missing?

Thank you for the help!
Below are some of the relevant files for completeness.


config file

# Loads default set of integrations. Do not remove.
default_config:

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensor.yaml

entities


sensor.yaml file:

- platform: command_line
  name: boiler_temperatuur
  command: "curl http://Pw3bus4r:[email protected]:4321/w8w0rd/ww1.L_ontemp_act"
  #value_template: '{{value_json["LOCAL.L_ww[0].einschaltfuehler_ist"] | multiply(0.10 ) | round(1) }}'
  unit_of_measurement: "°C"

- platform: command_line
  name: flame_temperatuur
  command: "curl http://Pw3bus4r:[email protected]:4321/w8w0rd/pe1.L_frt_temp_act"
  #value_template: '{{value_json["FA[0].L_feuerraumtemperatur"] | multiply(0.10) | round(1) }}'
  unit_of_measurement: "°C"
  
- platform: command_line
  name: living_temperatuur
  command: 'http://Pw3bus4r:[email protected]:4321/w8w0rd/hk1.L_roomtemp_act'
  #value_template: '{{value_json["LOCAL.L_hk[0].raumtemp_ist"] | multiply(0.10) | round(1) }}'
  unit_of_measurement: "°C"

I have disables the ‘value template’ here because only this way the message “Wait at least 2500ms during requests.” pops up, otherwise it understandably shows “unknown”.

Is there a command you can send to get all the info (as long as it is less than 255 characters)?

Then split it up with template sensors.

I got it to work with (a lot of) help. I will post it here for future reference if somebody else needs this.
This should work for all OKOFEN style pellet central heating units. But of course your mileage may vary.

There is a command that you can extract all data from the heating unit, which will spit out a long JSON file.

http://Pw3bus3r:[email protected]:4321/w8w0rd/all?

It’s also worth noting there is a lot of usefull info if you just go to tha ‘base adress’ of the heater

http://*webuser*:*webpass*@*IP-adresss*:*JSONport*/*JSONpass*/

1. step1
Add this to the config file:

sensor: !include sensor.yaml

shell_command:
  okfload: bash /config/okofen load
  okfset: bash /config/okofen set "{{ key }}" "{{ value }}"

2. add a file named “okofen” without extension to the /config folder
The content of the file is a “black magic” script

#!/bin/bash

COMMAND=$1
FILE=okofen.json
BASEURL=http://192.168.0.xx:4321/w8w0rd

shift

launchurl () {
	CURL="curl -s $1"

	if [[ $# == 2 ]] ; then
		CURL="$CURL -o $2"
	fi

	RES=`$CURL`
	while [[ "$RES" == "Wait at least 2500ms during requests" ]]; do
		sleep 3
		RES=`$CURL`
	done
}

load () {
	URL=$BASEURL/all?
	launchurl $URL $FILE.tmp
	SIZE=`stat -c%s $FILE.tmp`

	if [[ $SIZE != 2917 ]] ; then
		iconv -f latin1 -t utf-8 $FILE.tmp > $FILE
	fi
	rm $FILE.tmp
	exit 0
}

get () {
	cat $FILE	
	exit 0
}

iset () {
	URL=$BASEURL/$1=$2
	launchurl $URL
}

case $COMMAND in

	load) load $@ ;;
	get)  get  $@ ;;
	set)  iset $@ ;;
esac

3. add a file named “sensor.yaml” to the /config folder
with the sensors you want to extract from the JSON file. This is my example to get 3 values which are devided by 10 and rounded for convenience:

  - platform: command_line
    command: bash /config/okofen get
    value_template: '{{value_json["ww1"]["L_ontemp_act"]["val"]|multiply(0.1) | round(1)}}'
    name: boiler_temperatuur
    unit_of_measurement: "°C"
    
  - platform: command_line
    command: bash /config/okofen get
    value_template: '{{value_json["pe1"]["L_frt_temp_act"]["val"]|multiply(0.1) | round(1)}}'
    name: vlam_temperatuur
    unit_of_measurement: "°C"
    
  - platform: command_line
    command: bash /config/okofen get
    value_template: '{{value_json["hk1"]["L_roomtemp_act"]["val"]|multiply(0.1) | round(1)}}'
    name: living_temperatuur
    unit_of_measurement: "°C"

4. to use the value set function an an automation use shell_command.okfset
key = the value adress according to your kettle JSON file
value = the value to set, this can be a number or ‘true’, ’ false’, …
example:

  - service: shell_command.okfset
    data:
      key: ww1.heat_once
      value: 1