I create a "Text" device in a python plugin
Like this:
Domoticz.Device(Name="lowestPriceToday", Unit=3, TypeName="Text",Options=7).Create()
and attempt to update like this:
Devices[3].Update(nValue=price, sValue="{:.2f} €".format(price))
where price is a float.
I get this error:
2024-09-11 14:52:11.172 Error: Next Energy: (CDevice_update) Next Energy - lowestPriceToday: Failed to parse parameters: 'nValue', 'sValue', 'Image', 'SignalLevel', 'BatteryLevel', 'Options', 'TimedOut', 'Name', 'TypeName', 'Type', 'Subtype', 'Switchtype', 'Used', 'Description', 'Color' or 'SuppressTriggers' expected.
2024-09-11 14:52:11.172 Error: Next Energy: Call to function 'CDevice_update' failed, exception details:
2024-09-11 14:52:11.172 Error: Next Energy: (CDevice_update) Next Energy - lowestPriceToday: Failed to parse parameters: 'nValue', 'sValue', 'Image', 'SignalLevel', 'BatteryLevel', 'Options', 'TimedOut', 'Name', 'TypeName', 'Type', 'Subtype', 'Switchtype', 'Used', 'Description', 'Color' or 'SuppressTriggers' expected.
2024-09-11 14:52:11.172 Error: Next Energy: Call to function 'CDevice_update' failed, exception details:
2024-09-11 14:52:11.173 Error: Next Energy: Exception: 'TypeError'. No traceback available.
Any suggestions?
This is running on Raspian Buster, with Domoticz 2024.7
Update van "Text" device fails
Moderator: leecollings
-
- Posts: 7
- Joined: Friday 26 February 2016 13:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Update van "Text" device fails
Python plugin framework normally follows the API method for updating devices.
So for a text sensor see wiki page https://www.domoticz.com/wiki/Domoticz_ ... ext_sensor
nvalue=0
svalue=TEXT = Text you want to display
In your case nvalue=price will not be nvalue=0 so could give an error.
So for a text sensor see wiki page https://www.domoticz.com/wiki/Domoticz_ ... ext_sensor
nvalue=0
svalue=TEXT = Text you want to display
In your case nvalue=price will not be nvalue=0 so could give an error.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 7
- Joined: Friday 26 February 2016 13:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Update van "Text" device fails
Thanks for the reply. But the device with index 2 gives the same error where there is an sValue and the nValue = 0
This update for a similar items fails the same way:
Devices[2].Update(nValue=0, sValue=hours_lowest[0])
and was created as:
Domoticz.Device(Name="lowestEnergyTOD", Unit=2, TypeName="Text",Options=7).Create()
This update for a similar items fails the same way:
Devices[2].Update(nValue=0, sValue=hours_lowest[0])
and was created as:
Domoticz.Device(Name="lowestEnergyTOD", Unit=2, TypeName="Text",Options=7).Create()
-
- Posts: 621
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: Update van "Text" device fails
Just thinking out loud....
The errormessage indicates a type error of the passed parameters, but your are passing a 0 and you are passing a string (although some strange € characters in the string, but when I try it in a normal python program it does not trigger an error), so you don't seem to be doing anything wrong.
To me it is not clear what the "options=7" means during device creation. I can't find a clear explanation of that in the wiki.
Is it necessary to use it for a text device? What if you try without? Could it have to do with the error?
I normally would used Type=243, Subtype=19 without any options parameter.
And what if you try with a simpler string, like just sValue="abc"? Same error?
The errormessage indicates a type error of the passed parameters, but your are passing a 0 and you are passing a string (although some strange € characters in the string, but when I try it in a normal python program it does not trigger an error), so you don't seem to be doing anything wrong.
To me it is not clear what the "options=7" means during device creation. I can't find a clear explanation of that in the wiki.
Is it necessary to use it for a text device? What if you try without? Could it have to do with the error?
I normally would used Type=243, Subtype=19 without any options parameter.
And what if you try with a simpler string, like just sValue="abc"? Same error?
-
- Posts: 7
- Joined: Friday 26 February 2016 13:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Update van "Text" device fails
Yes, when I put "Unknown" as string, the same result.
I saw this Options=7 in some other plugin, without it, creation fails... Indeed I have not clue what is....
Trial and Error...
I could try defining it with Type, subtype instead op the "Text" parameter...
I saw this Options=7 in some other plugin, without it, creation fails... Indeed I have not clue what is....
Trial and Error...
I could try defining it with Type, subtype instead op the "Text" parameter...
-
- Posts: 621
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: Update van "Text" device fails
also try adding "used=1" (default seems to be 0=not used)hvanschaick wrote: ↑Thursday 12 September 2024 9:16 Yes, when I put "Unknown" as string, the same result.
I saw this Options=7 in some other plugin, without it, creation fails... Indeed I have not clue what is....
Trial and Error...
I could try defining it with Type, subtype instead op the "Text" parameter...
-
- Posts: 7
- Joined: Friday 26 February 2016 13:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Update van "Text" device fails
Ok, fixed. My Bad. The string was not a proper string...
-
- Posts: 621
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: Update van "Text" device fails
So how come it also failed when you used "Unknown" as string?hvanschaick wrote: ↑Thursday 12 September 2024 10:18 Ok, fixed. My Bad. The string was not a proper string...
Who is online
Users browsing this forum: Bing [Bot] and 1 guest