-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements to the API #46
Comments
For integration into other home automation systems short names (datafield names) would be needed for rest API json. |
either we make it all use shortnames (my preference) or have an configurable option short/verbose in the WebUI or make an additional command for verbose naming like |
There was a discussion a while ago, can't remember the number. As result: v2 only uses short names, the long ones are not available for API. v3 defaults to long names (id=-1), with id=0,1..4 output is compatible with v2. Edit: Discussion was in #698, I've checked the output on my system and works as expected, can't see any formatting issue or bug. |
@MichaelDvP @proddy It should be better within documentation .... (if even @proddy does not remember anymore :) and not just new for me...) |
Yes, the doc is based on v2.2.1 as mentioned here, and most people using v2, there is not an extra doc for v3. |
I would recommend to avoid unnecessary API / MQTT changes between v2 and v3. So why not keeping short names by default in v3 for cmd=info and adding a new command cmd=verbose for full names? When trying to build interfaces the respective number values are important and not so much the corresponding expressions. I would highly appreciate If a new command per device or datafield could be introduced: cmd=config which returns: |
That's true! I'm so occupied with work these days I'm started to forget what we coded in EMS-ESP. Luckily Michael seems to have a memory like an elephant. Creating a new API command that sends back a JSON array with the id, shortname, type, writeable is possible. If that really helps. And @MichaelDvP adding a min & max value or an enum would also be handy, especially in the new Web UI where values can set and also used in Home Assistant (and perhaps Domoticz). |
Only problem is, that we do not know the min/max and they differ for different boiler/thermostat types. If someone provides this data for all types it can be done. But it's a lot of work with only little value even if we have a table with all data. |
good point. it's a lot of guess work and there are bound to be many variations across our 80 supported devices. |
I support your argument that it is difficult to get the configurations for 80 supported devices. Nevertheless there are a couple of critical parameters valid for all devices where a min/max value control should be implemented at least within ems-esp firmware to secure stable operations of heating system and avoiding wrong end-user input. Direct changes by ems-bus are anyhow critical, so I would strongly recommend that some basic testing routines on valid ranges should be implemented for the most critical datapoints. These are only a few:
While writing an interface to home automation systems I would like to get your feedback on how to implement this input control? Since I use MQTT as an interface to the respective ems-esp ioBroker-adapter I programmed, any commands for changes I send by mqtt are not replied and therefore can not be checked if an error happened. E.g. trying to change a field which is not writable. |
Yes, I would only use the rest API for doing write operations. If the command is not writable it'll come back with an error like "Invalid cmd". When I finally get to moving the web server and adding SSL the API will change and be more according to the proper API standards (like https://stackoverflow.blog/2020/03/02/best-practices-for-rest-api-design/) and make it easier for you. I do agree adding some validation to the write settings would be useful. I've had to do a number of factory resets on my boiler when testing and setting bogus values by mistake. Need to think about that one. It's a lot of work as Michael said! |
I've renamed this issue, as it was originally about the info command and hidden feature to get short-names. Now it's about general improvements to the API and an additional command to bring back the capabilities. |
And here is the problem i mentioned, half of the ranges you describe is not right for my boiler. hyston can be positive, usefull to have an offset, wwsettemp is limited to min:30 for me, disinfection can be 80, and so on. And i think this is also for much more values (like modulation-ranges specific for pump-types or burners). Also enum-values differ much, e.g. building light/medium/heavy is 0,1,2 for RC35, but 1,2,3 for RC300, some thermostats uses modesettings off/on/auto, some off/auto/on, and so on.
All commands makes a postvalidation with a bus-read and publishes the result out of order via mqtt. We have also the publish of topic To check for writeable commands v3 has the option for direct subscribes, which will show a handy list of all commands. |
@tp1de I've pushed a version with info for each value. Working on API, mqtt and console. Output is a json like
Min/max is set in enum for possible values, all number values gives the range of storage (int/short/long), value is only set if there is a valid value. |
this is super. I will wait for further changes on the ioBroker Adapter until you are finished.
Are you intending to include the enum-values and as well or can't this be done? |
I tested the new version. Units and writable info seems to work fine
e.g. controlmode can be 1 or 2 (outside / inside) |
The delay in publish device_data after sending a value is from ems-bus, We send the new value, read it back from bus and publish immediatly the mqtt. Only readback from different telgrams is delayed, because the device needs some time to set it. Mqtt-response-feedback for the value-info is immediatly, it triggers no bus bus-activity and do not have to wait.
Do you mean the names? How? As json-array
For RC300 it is |
The km200 reply from http get returns for allowed values (enums) an array for allowedValues with number and strings: array[3] I have seen that in the dashboard values are now changeable as well. For enum you need to know what to enter. A drill-down menu would be easier.
I just checked on my RC310. I was wrong too. I have 3 choices: outdoor / outdoor with footpoint / indoor. I do not know if it is worthwhile maintaining key variants or if it is possible to make the enum values configurable in ems-esp. |
Do you mean an array with
I can't find this setting in Norberts list. You have to log a change to find the telegram and place. |
yes a nested json with array like you described (similar to km200 get return json) . Your proposal is excellent!
There are a couple of other changes and missing datafields compared to km200. |
@MichaelDvP |
@MichaelDvP
By trying to poll on devices within this nested json and taking Maybe it is worthwhile considering to add an entry |
As mentioned it is already implemented for console, API and mqtt. A few values with command only (temp, wwtapactivated, reset) are missing for now. Coming soon. I'll also want to implement id/hc to get the value from a specific heating circuit, Since the console command can not have id without data, i'll use a wildcard |
Ok, i'll convert the input to lowercase before comparing. |
Yes you are right - I haven't understood the command. |
.... and should the name not include the heating circuit? e.g. hc1.designtemp / hc2.designtemp |
Switch your browser view/textcoding from uincode to auto or utf8. Degree is not ascii and depends on charset. |
I haven't found a way in the browser (firefox / chrome or edge) if I enter directly in the adressfield. Shouldn't utf8 not beeing defined from ems-esp response? Nevertheless if I send a http get request from javascript with utf8 encoding I get in return the right characters .... |
Yes, set |
I've pushed the id/prefix, device-lowercase, and utf-8 changes. Also made a test with min/max stored for each value, but it's a lot of change and extra memory and @proddy have to check if it fit's in his plans for ems-esp. |
@MichaelDvP By the way: min/max values are only needed for writeable fields. |
@MichaelDvP I want to seperate boiler (heating) and ww fields like beeing done by mqtt topic by reading fields now with rest API. Can this be done by reading the first two letters from fieldname |
@MichaelDvP |
The device boiler contains one field |
Since I am implementimg the ioBroker adapter based on rest api rather then mqtt, I recognized that the mqtt heartbeat and the system device info by rest api are different. |
both really minor changes, I can do it or Michael if you're still busy with the code? |
I've fixed the wwHeat, but see the others to late. Create a API-System-info-id0 with shortnames is a bit more to do. I can do it tomorrow. |
thanks Michael! |
I thought about it and found a simple solution that ensures that output is the same. |
Sorry Michael a bit too fast ..... now the I need to read the |
@MichaelDvP I changed my adapter to select one system part without id and Status part by using id=0 Thanks a lot for your support @MichaelDvP and @proddy P.S. Next steps would be to compare the enums (allowedStates) - I see some differences between ems-esp and km200 |
As reported from @tp1de
While using rest api the return values from info command per device returns json on data fields with description and not with names of data fields.
Is there any reason why not returning the field names? By the way when using the id return json is different and contains datafield names:
eg mixer http://ems-esp/api?device=mixer&cmd=info vs http://ems-esp/api?device=mixer&id=2&cmd=info:
{"(hc2) setpoint flow temperature":27,"(hc2) flow temperature in assigned hc (TC1)":29,"(hc2) pump status in assigned hc (PC1)":"on","(hc2) mixing valve actuator in assigned hc (VC1)":5}
{"id":160,"flowsettemp":27,"flowtemphc":29,"pumpstatus":1,"valvestatus":5}
Two things to do here:
The text was updated successfully, but these errors were encountered: