Coding Help with Rest Sensor and Dynalite temperatures

I’m pretty new to this so excuse me if this is easy. I’ve been working on it for days to get to this point. I am getting temperature information from Dynalite Antumbra light switches. The official Dynalite integration which I am using for the lights does not have temperature support.

Dynalite has an ethernet gateway that I can POST to and get responses about the temperature.
The post looks like:

http://192.XXX.XXX.XXX/GetDyNet.cgi?a=11&TEMPERATURE

Where a=11 Is the switch in Dynalite area 7

Response looks like:
t=21.46
which is 21.46 degrees celcius

I have this working - but only just. Currently using 7 switches but would like to use more.

2 parts to my question.

  1. How can I better structure my code so it isn’t so verbose? Can I loop it or take an input file?

  2. The ethernet gateway doesn’t seem capable of responding to simultaneous requests and fails to respond to some on the first try. It takes a long time to create the entities after reboot. (This is why I have varied the scan intervals)

My code:
(Have only included 2 switches - but you get the idea. Would be very long for 20+ switches).

sensor:
# Kids study temperature
  - platform: rest
    name: Kids Study Temp
    resource: http://192.XXX.XXX.XXX/GetDyNet.cgi?a=10&TEMPERATURE
    value_template: "{{ value.split('=')[1] | float }}"
    scan_interval: 177
    unit_of_measurement: '°C'
# Family TV room temperature
  - platform: rest
    name: Family TV Temp
    resource: http://192.XXX.XXX.XXX/GetDyNet.cgi?a=41&TEMPERATURE
    value_template: "{{ value.split('=')[1] | float }}"
    scan_interval: 191
    unit_of_measurement: '°C'

Any tips or better ideas about the approach?

Hey Hound,
Sorry to hijack the post, how do you setup the gateway to accept http requests?

Are you using the Dynalite PDEG gateway or an after market one?

Dynalite PDEG

The PDEG should respond by default. I assume you have Dynalite integrated to HA? Your switches may not be assigned to areas. Try the following to see if the http posts are working.

Enter the following in your browser

http://192.168.2.XXX/SetDyNet.cgi?a=21&p=1

Substitute the IP address 192.168.2.XXX with the address of your PDEG
Substitute a=21 with an area from your lighting network - see your YAML

This should turn the lights on in that area

http://192.168.2.XXX/SetDyNet.cgi?a=21&p=4

Should turn the lights off.

Does this work?

Actually you can just try

http://192.XXX.XXX.XXX/GetDyNet.cgi?a=10&TEMPERATURE

Even if the area is not set up, you should still get a response of “t=.”
If the area is set up, you should get “t=19.26” for example

Screen Shot 2022-07-05 at 11.11.13 am

I dont get a response on port 80, its seems like there is a setting to enable it ??

Don’t use wget. Just paste the command in the URL field of your browser

Ill give it a go when I get home

No luck, is there a system builder setting ?

If you have system builder, you can check this setting in your gateway. Mine is enabled.