JSON fields with a '-' (hyphen) in their name [Solved]
Moderator: leecollings
-
rjblake
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
JSON fields with a '-' (hyphen) in their name
Help - I'm trying to update some devices using the JSON being returned from a call to a device. However, the fields/variables are all named with a hyphen (e.g. door-state, light-state, etc.). When I try to assign these to a variable in dzVents, (local garage_door = item.json.door-state), I get an error "... attempt to perform arithmetic on field 'door' (a nil value)". I assume this is because of the '-' and trying to subtract state from door. How can I uses this naming convention in dzVents?
-
dannybloe
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: JSON fields with a '-' (hyphen) in their name
item.json['door-state']
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
rjblake
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
Re: JSON fields with a '-' (hyphen) in their name
Many thanks - could not for the life of me work out the required syntax. Too many damn programming languages floating around in my aging brain!
-
dannybloe
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: JSON fields with a '-' (hyphen) in their name [Solved]
Yup.. just follow this presentation and you're good to go: https://www.lua.org/pil/1.html
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Who is online
Users browsing this forum: Bing [Bot] and 1 guest