Re: [mh] Adding ability to send arbitrary commands to Tasmota
Paul Onley <[email protected]>
| Newsgroups | gmane.comp.misc.misterhouse.user |
|---|---|
| Message-ID | <[email protected]> |
Very good point Jeff, I just want to point out that anyone who has code
based on using MQTT_DEVICE to obtain the status from Tasmota will need
to change that code as parse_json returns all lower case keys from
MQTT_DEVICE and proper Tasmota case with data returned from
Tasmota_HTTP::Item. MQTT_DEVICE probably should have returned the JSON
as Tasmota reports it but the question now is do you change course and
have two different return values depending on where the data comes from
or adjust one source to have consistent data over the whole of mh?
Frankly I'm in a little over head here, the ultimate decision is up to
the programmers (you and Giles), I only brought it up as the code I had
written using MQTT_DEVICE to get status did not work with
Tasmota_HTTP::Item until I realized the case difference. The new
Tasmota_HTTP::Item code makes for a much simpler and cleaner .mht and
simpler more consistent way to access all of Tasmota's features but what
is the best approach to keep things as simple and consistent across mh
as a whole? If someone uses MQTT_DEVICE for a device with firmware other
than Tasmota and Tasmota_HTTP::Item for Tasmota devices they would have
to use different code to handle the data based on which source it comes
from even though it should be the same JSON from either.
The whole MQTT aspect of mh is still pretty young and I appreciate all
the work you guys have done here, I could never have implemented these
new devices without your hard work.
On 2/3/21 1:06 PM, Jeff Siddall via misterhouse-users wrote:
> I vote to keep the Tasmota_HTTP::Item is returning the raw data.
> Anyone familiar with Tasmota will expect the MH data to align with
> what they see on the Tasmota itself.
>
> Jeff
>
>
> On 2021-02-03 1:32 p.m., Giles Godart-Brown wrote:
>>
>> Thanks for the spot Paul, I only do an lc when no command is sent,
>> and returning on or off to be consistent with MisterHoues, but not
>> otherwise.
>>
>> I believe I saw this in the mqtt code too, I need to do some more
>> digging in the morning
>>
>> Giles
>>
>> On 03/02/2021 18:26, Paul Onley wrote:
>>> Giles,
>>>
>>> I noticed that the case of fields in the returned JSON is different
>>> between MQTT_DEVICE and the new Tasmota_HTTP::Item code. The
>>> Tasmota_HTTP::Item result seems to be consistent with the actual
>>> mqtt telemetry, is the MQTT_DEVICE code performing a lower() on the
>>> data or something?
>>>
>>> {"StatusSNS":{"Time":"2021-02-03T12:15:01","ENERGY":{"TotalStartTime":"2021-02-03T12:14:01","Total":0.000,"Yesterday":0.000,"Today":0.000,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":0,"Current":0.000}}}
>>>
>>> {"time":"2021-02-03t12:14:07","energy":{"totalstarttime":"2021-02-03t12:14:01","total":0.000,"yesterday":0.000,"today":0.000,"period":0,"power":0,"apparentpower":0,"reactivepower":0,"factor":0.00,"voltage":0,"current":0.000}}
>>>
>>>
>>> Paul
>>>
>>> On 2/2/21 5:17 AM, Giles Godart-Brown wrote:
>>>>
>>>> All
>>>>
>>>> I've just created a pull request to extend Tasmota_HTTP::Item by
>>>> adding a run_cmnd subroutine to send arbitrary commands to a
>>>> MIsterHouse Tasmota item.
>>>>
>>>> * It returns the JSON response from the Tasmota and sets
>>>> $self->{run_cmnd_response} and $self->{last_http_status}
>>>> * It URL encodes the command so user doesn't need to
>>>> * If no command sent it decodes the json and returns the state of
>>>> the device e.g.
>>>> o $device->run_cmnd() returns on or off
>>>> o $device->run_cmnd('status 10') returns a json string of the
>>>> sensor status
>>>> o $device->run_cmnd('restart 1') reboots the Tasmota
>>>>
>>>> I hope people find this helpful
>>>>
>>>> Giles
>>>>
>>>>
>>>>
>>>> ________________________________________________________
>>>> To unsubscribe from this list, go
>>>> to:https://lists.sourceforge.net/lists/listinfo/misterhouse-users
>>>>
>>>
>>>
>>>
>>> ________________________________________________________
>>> To unsubscribe from this list, go
>>> to:https://lists.sourceforge.net/lists/listinfo/misterhouse-users
>>>
>>
>>
>> ________________________________________________________
>> To unsubscribe from this list, go to:
>> https://lists.sourceforge.net/lists/listinfo/misterhouse-users
>>
>
>
> ________________________________________________________
> To unsubscribe from this list, go to:
> https://lists.sourceforge.net/lists/listinfo/misterhouse-users
>
________________________________________________________
To unsubscribe from this list, go to: https://lists.sourceforge.net/lists/listinfo/misterhouse-users