andreasnuesslein / py-teleco-daisy

MIT License
1 stars 2 forks source link

Some device types are missing #2

Open glpotatoe opened 3 months ago

glpotatoe commented 3 months ago

Hi,

I have a pergola, and the extension wasn’t displaying my devices. I noticed that in the “teleco_daisy.py” file, only types 23 and 24 are tested. However, in my configuration, lights correspond to type 21, and covers correspond to type 22. So, I modified the code as follows, and it seems functional: if device["idDevicetype"] in (23, 21): [...] elif device["idDevicetype"] in (24, 22):

I haven’t tested it in HomeAssistant yet, so you might need to update the “teleco_daisy” dependency, currently at version 0.1.0.

I’m available for testing if needed.

Thank you!"

andreasnuesslein commented 3 months ago

Hi @glpotatoe thanks for this ticket. You're right: many devices are missing. I was only able to add 23 and 24 because those are the ones that I have :D

Could you give me some infomation what your devices can do? I'm assuming they are maybe not RGB-LEDs? and what kind of pergola motorization do you have?

cheers

glpotatoe commented 3 months ago

Hi @andreasnuesslein !

Thank you for your feedback.

Indeed, I have several devices and motorizations. I will take screenshots of the Daisy application.

Feel free to ask for additional information if needed. I can also provide the JSON returned by the APIs as necessary.

andreasnuesslein commented 3 months ago

Hey @glpotatoe so I moved it here because it's about this little library.

Maybe you could check out this project, edit the device IDs like you said above and then do:

from teleco_daisy import TelecoDaisy

tdai = TelecoDaisy("yourusername","yourpassword")
tdai.login()
for inst1 in tdai.get_account_installation_list():
    for r1 in tdai.get_room_list(inst1):
        for d1 in r1.deviceList:
            print(tdai.status_device_list(inst1, d1))
glpotatoe commented 3 months ago

Hi @andreasnuesslein

Here is the result :

[DaisyStatus(idInstallationDeviceStatusitem=98816, idDevicetypeStatusitemModel=41, statusitemCode='OPEN_CLOSE', statusItem='OPEN_CLOSE', statusValue='STOP', lowlevelStatusitem=''), DaisyStatus(idInstallationDeviceStatusitem=98817, idDevicetypeStatusitemModel=72, statusitemCode='LEVEL', statusItem='LEVEL', statusValue='100', lowlevelStatusitem=None)]
[DaisyStatus(idInstallationDeviceStatusitem=98818, idDevicetypeStatusitemModel=20, statusitemCode='POWER', statusItem='POWER', statusValue='OFF', lowlevelStatusitem=None), DaisyStatus(idInstallationDeviceStatusitem=98819, idDevicetypeStatusitemModel=21, statusitemCode='LEVEL', statusItem='LEVEL', statusValue='0', lowlevelStatusitem=None)]
[DaisyStatus(idInstallationDeviceStatusitem=98820, idDevicetypeStatusitemModel=32, statusitemCode='OPEN_CLOSE', statusItem='OPEN_CLOSE', statusValue='OPEN', lowlevelStatusitem=None), DaisyStatus(idInstallationDeviceStatusitem=98821, idDevicetypeStatusitemModel=70, statusitemCode='LEVEL', statusItem='LEVEL', statusValue='100', lowlevelStatusitem=None)]       
[DaisyStatus(idInstallationDeviceStatusitem=98822, idDevicetypeStatusitemModel=32, statusitemCode='OPEN_CLOSE', statusItem='OPEN_CLOSE', statusValue='OPEN', lowlevelStatusitem='OPEN_CLOSE=OPEN'), DaisyStatus(idInstallationDeviceStatusitem=98823, idDevicetypeStatusitemModel=70, statusitemCode='LEVEL', statusItem='LEVEL', statusValue='100', lowlevelStatusitem='LEVEL=100')]
[DaisyStatus(idInstallationDeviceStatusitem=98824, idDevicetypeStatusitemModel=32, statusitemCode='OPEN_CLOSE', statusItem='OPEN_CLOSE', statusValue='OPEN', lowlevelStatusitem='OPEN_CLOSE=OPEN'), DaisyStatus(idInstallationDeviceStatusitem=98825, idDevicetypeStatusitemModel=70, statusitemCode='LEVEL', statusItem='LEVEL', statusValue='100', lowlevelStatusitem='LEVEL=100')]
andreasnuesslein commented 2 months ago

hi @glpotatoe sorry very busy these days. will look into it when i have a few minutes to spare. but maybe, since you've come this far already.. :) the code is really really simple. maybe you can fiddle around yourself a bit more.

i.e. if your light is white-only, maybe you can adapt the code a bit? although thinking about it, you'd probably have to modify the DaisyLight class a bit more to accomodate the non-rgb-ness.

if you can create a PR, great, if not i will look into it a bit too some time

osteward commented 1 month ago

Hi, @andreasnuesslein -- first, thank you for creating this! Like the other poster, I have a slightly different Teleco setup. The good news is the louvre controls work perfectly. The lights however, do not. I have single colour dimmable lights (again, similar to previous poster). I have been able to edit the code to adjust the 'type' which means the light show up in HomeAssistant, but the control then does not work.

I'm happy to try and update the code myself to make everything work - I am a very basic programmer though, so what I am trying to do first is 'post' the commands manually to the Teleco API to make sure the commandAction, commandId, and commandParam are correct - as I believe these may differ with the new lights?

I can make all the initial commands work to list devices, etc. I can't however make the 'send commands' part work. Below is the JSON I am trying to send, pieced together from looking at your code. It attempts to control the louvres, as they should work given the HomeAssistant integration does?

When I post howver, I receive the following error:

{
    "MessageID": "WS-100",
    "MessageText": "Body Error",
    "MessageType": "WARNING"
}

So, I assume my JSON is incorrect somehow. Below is what I am trying to post - do you have any ideas about what is going wrong? (I have removed the idInstallation and idSession for security, but everything else is as-is.)

Thank you so much for any help! And thank you again for creating this!

Post to: https://tmate.telecoautomation.com/teleco/services/tmate20/feedthecommands/

{
    "commandsList": [
        {
            "deviceCode": "0",
            "idInstallationDevice": xxxxx,
            "commandAction": "OPEN_STOP_CLOSE",
            "commandId": 96,
            "commandParam": "CLOSE",
            "lowlevelCommand": "CH1"
        }
    ],
    "idInstallation": xxxx,
    "idSession": "xxxx",
    "idScenario": 0,
    "isScenario": false
}
AdamFiser commented 1 month ago

Hi @osteward, I'm not sure @andreasnuesslein has the space to pursue this now. Anyway, if you don't have direct access to the device, it's very hard to test. I just got access to a daisy box this week and am starting to integrate our equipment. Unfortunately progress will be a little slower as I only have physical access on the weekend. Maybe we have the same light. Coincidentally, I started a new #4 a while ago

For starters, if you want to anonymize, delete the idInstallationDevice value. deviceCode is always the same

I recommend using postman to work with the API, it makes the job a lot easier.

I haven't encountered a ws-100 error yet, but there will be an error in the message content. For now, I found that you need to identify the commandId, commandParam and possibly lowlevelCommand correctly. And what values should be there?

https://tmate.telecoautomation.com/teleco/services/command-device-list POST:

{
    "idAccount": 3333,
    "idSession": "xxxx",
    "idInstallation": 6666,
    "idInstallationDevice": 99999
}

Response:

"commandList": [
 {
                "idInstallationDeviceCommand": 571915,
                "idDevicetypeCommandModel": 147,
                "commandCode": "POWEROFF",
                "commandAction": "POWER",
                "commandParam": "OFF",
                "lowlevelCommand": "CH8",
                "deviceIndex": 0
            },

The full response is in #4

Your sample response is from the slats, not the light. In the body post edit idInstallationDevice and set to light. If you don't know it, send an post to https://tmate.telecoautomation.com/teleco/services/room-list

The command list shows the most important commandId, commandparam and lowLevelCommand. These must be sent exactly according to the device. Since each device has its own combinations, I created #3 to make it easy to add new devices in the code. Help with integration is appreciated.

osteward commented 1 month ago

@AdamFiser thank you for the response! Yes it seems like we have the same light. The 'command device list' link is very helpful - thank you. I am using Postman as you suggest, and will report back either here or in the other issues you've created with further details as I progress

osteward commented 1 month ago

@AdamFiser our lights are the same device type but a different device model -- I have posted details in #4 - let me know if you need any other information?

I am still having trouble posting a command - using Postman. Could you share a sample JSON of a successful command you've sent, via the 'feedthecommands' call so I can try and figure out what I'm doing wrong?

Thank you very much

AdamFiser commented 1 month ago

@osteward Thank you for sharing, I will keep the specifics in mind during implementation.

@AdamFiser our lights are the same device type but a different device model -- I have posted details in #4 - let me know if you need any other information?

I am still having trouble posting a command - using Postman. Could you share a sample JSON of a successful command you've sent, via the 'feedthecommands' call so I can try and figure out what I'm doing wrong?

Thank you very much

I haven't called feedthecommands directly through the api yet. I sent the commands through python by calling the corresponding library functions.

I copied it directly and it needs light editing especially replacing the values from the original python source

                "commandsList": {
                    "deviceCode": str(self.deviceIndex),
                    "idInstallationDevice": self.idInstallationDevice,
                    "commandAction": "OPEN_STOP_CLOSE",
                    "commandId": c_id,
                    "commandParam": c_param,
                    "lowlevelCommand": c_ll,
                },
                "idInstallation": installation.instCode,
                "idSession": self.idSession,
                "idScenario": 0,
                "isScenario": False,

If you want to do a lot of research, this is what the model looks like from the API that accepts commands FeedCommandPost.java

package com.telecoautomation.daisy.cloud.model;

import java.util.List;

public class FeedCommandPost {
    List<CommandCloud> commandsList;
    private String idInstallation;
    private int idScenario;
    private String idSession;
    private boolean isScenario;

    public String getIdInstallation() {
        return this.idInstallation;
    }

    public void setIdInstallation(String str) {
        this.idInstallation = str;
    }

    public String getIdSession() {
        return this.idSession;
    }

    public void setIdSession(String str) {
        this.idSession = str;
    }

    public int getIdScenario() {
        return this.idScenario;
    }

    public void setIdScenario(int i) {
        this.idScenario = i;
    }

    public boolean isScenario() {
        return this.isScenario;
    }

    public void setScenario(boolean z) {
        this.isScenario = z;
    }

    public List<CommandCloud> getCommandsList() {
        return this.commandsList;
    }

    public void setCommandsList(List<CommandCloud> list) {
        this.commandsList = list;
    }
}
osteward commented 1 month ago

@AdamFiser Thank you - appreciate it

AdamFiser commented 1 month ago

Hi @glpotatoe support for device id 22 is registered in #5. I sent a pull request #6 to add support for this device.

glpotatoe commented 1 month ago

Hi @AdamFiser !

Thank you for the work on this integration, and these issues. I copied the custom component from main branch to my home assistant instance, add integration with my credentials, and no devices appears. Did I miss something ?

Also, the "automatic intrgration" trough HACS doesn't work, with error :

<Integration andreasnuesslein/hass_teleco_daisy> Repository structure for 0.1.0 is not compliant"