Update van "Text" device fails

Python and python framework

Moderator: leecollings

Post Reply
hvanschaick
Posts: 7
Joined: Friday 26 February 2016 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Update van "Text" device fails

Post by hvanschaick »

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
User avatar
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

Post by waltervl »

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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
hvanschaick
Posts: 7
Joined: Friday 26 February 2016 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Update van "Text" device fails

Post by hvanschaick »

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()
willemd
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

Post by willemd »

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?
hvanschaick
Posts: 7
Joined: Friday 26 February 2016 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Update van "Text" device fails

Post by hvanschaick »

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...
willemd
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

Post by willemd »

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...
also try adding "used=1" (default seems to be 0=not used)
hvanschaick
Posts: 7
Joined: Friday 26 February 2016 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Update van "Text" device fails

Post by hvanschaick »

Ok, fixed. My Bad. The string was not a proper string... :oops:
willemd
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

Post by willemd »

hvanschaick wrote: Thursday 12 September 2024 10:18 Ok, fixed. My Bad. The string was not a proper string... :oops:
So how come it also failed when you used "Unknown" as string?
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest