hugheaves / mios_wifi-thermostat

Provides support for the 3M-50 and other Radio Thermostat / Filtrete thermostats using the Wi-Fi USNAP module.
6 stars 4 forks source link

Alexa Integration #6

Open jbonzey opened 7 years ago

jbonzey commented 7 years ago

alexa-radiothermostat-master.zip Hi Hugh - I've been trying to figure out how to get my Radio Thermostat 3m50s to work with Alexa. I have the Vera / Alexa beta code operational and all my scenes/devices work. However there is an issue with the radio thermostat wifi plugin not liking the commands it is seeing from Alexa.

Vera integrated the generic thermostat skillset. Amazon Alexa sends the command TemperatureSetpoint1 vs the plugin requirement TemperatureSetpoint1_Heat

Can you tell me where I would change the command in the source files to get the plugin to accept the TemperatureSetpoint1 command coming in from alexa? I have attempted to change the commands in a bunch of locations but to be honest i'm guessing and can't figure it out.

Any help would be greatly appreciated. My plan would be to just hardcode the _Heat where necessary and change it to _Cool in the summer.

Thanks

hugheaves commented 7 years ago

That's strange, actually. Are you running on UI5 or UI7?

jbonzey commented 7 years ago

U17. Thanks. It's definately looking for the _Heat added to execute the command

jbonzey commented 7 years ago

Hi Hugh - could you let me know where I need to modify the _Heat in your code to get this to work with alexa? Thanks a lot

hugheaves commented 7 years ago

Hi jbonzey,

It sounds like the Alexa plugin is kinda broken.

That said, I think you'd need:

  1. Modify D_RTCOA_Wifi_ZoneThermostat1.xml to add a third "TemperatureSetPoint1" service without heat / cool:
<service>
  <serviceType>urn:schemas-upnp-org:service:TemperatureSetpoint:1</serviceType>
  <serviceId>urn:upnp-org:serviceId:TemperatureSetpoint1</serviceId>
  <SCPDURL>S_TemperatureSetpoint1.xml</SCPDURL>
</service>
  1. Add a third action to I_RTCOA_Wifi_ZoneThermostat1.xml to handle the new service:

        <action>
            <serviceId>urn:upnp-org:serviceId:TemperatureSetpoint1_Cool</serviceId>
            <name>SetCurrentSetpoint</name>
            <job>
                return g_core.dispatchJob(lul_device, lul_settings, lul_job,
                "urn:upnp-org:serviceId:TemperatureSetpoint1", "SetCurrentSetpoint")
            </job>
        </action>
  2. Modify L_RTCOA_Wifi_core.lua:

At the top add: local SETPOINT_SID = "urn:upnp-org:serviceId:TemperatureSetpoint1"

Inside dispatchJob:

if (serviceId == USER_OPERATING_MODE_SID and action == "SetModeTarget" or
    serviceId == FAN_MODE_SID and action == "SetMode" or
    serviceId == HEAT_SETPOINT_SID and action == "SetCurrentSetpoint" or
    serviceId == COOL_SETPOINT_SID and action == "SetCurrentSetpoint" or
    **serviceId == SETPOINT_SID and action == "SetCurrentSetpoint" or**
    serviceId == TEMPERATURE_HOLD_SID and action == "SetTarget") 

inside updateThermostatSetting: (set t_cool or t_heat, your choice -or you could make this smarter and set t_cool or t_heat depending on the current operating mode)

    elseif (serviceId == SETPOINT_SID and action == "SetCurrentSetpoint") then
        setLuupVariable(serviceId, "CurrentSetpoint", lul_settings.NewCurrentSetpoint, g_deviceId)
        **if (util.getLuupVariable(USER_OPERATING_MODE_SID, "ModeStatus", g_deviceId, util.T_STRING) == "CoolOn") then**
            settings = initSettings()
            **settings.t_cool = delocalizeTemp(lul_settings.NewCurrentSetpoint)**
            success = callThermostatAPI(TSTAT_API_THERMOSTAT_PATH, isValidUpdateResponse, settings)
        end
jbonzey commented 7 years ago

No matter what I do I keep getting the error within Vera below. I've changed the 3 files like stated above.

Couple questions:

  1. I assume I pull out the ** in your code changes? I tried it both ways and no difference.
  2. After making the modifications. All i'm doing is going into vera under development apps and uploading the 3 files. I only check the "restart luup after upload" on the 3rd file uploaded.
  3. There are 2 of the same files listed for all three files in the development apps table within vera. only one of each of the duplicate files has anything in it though. I'm assuming vera takes the last loaded file?

Sorry for all the noob questions.

luup_log:0: AAH::AlexaAction> Start <0x73ca2520> 50 03/15/17 15:39:38.421 luup_log:0: AAH::AlexaAction> Argument: serviceId=urn:upnp-org:serviceId:TemperatureSetpoint1 <0x73ca2520> 50 03/15/17 15:39:38.421 luup_log:0: AAH::AlexaAction> Argument: NewCurrentSetpoint=20 <0x73ca2520> 50 03/15/17 15:39:38.422 luup_log:0: AAH::AlexaAction> Argument: action=SetCurrentSetpoint <0x73ca2520> 50 03/15/17 15:39:38.422 luup_log:0: AAH::AlexaAction> Argument: DeviceNum=62 <0x73ca2520> 50 03/15/17 15:39:38.423 luup_log:0: AAH::AlexaAction> Call the action <0x73ca2520> 08 03/15/17 15:39:38.423 JobHandler_LuaUPnP::HandleActionRequest device: 62 service: urn:upnp-org:serviceId:TemperatureSetpoint1 action: SetCurrentSetpoint <0x73ca2520> 08 03/15/17 15:39:38.434 JobHandler_LuaUPnP::HandleActionRequest argument NewCurrentSetpoint=68 <0x73ca2520> 01 03/15/17 15:39:38.434 JobHandler_LuaUPnP::HandleActionRequest can't find urn:upnp-org:serviceId:TemperatureSetpoint1 <0x73ca2520> 50 03/15/17 15:39:38.435 luup_log:0: AAH::AlexaAction> ERROR: action call failed with code=401 and message: Invalid Service <0x73ca2520>

jbonzey commented 7 years ago

Disregard. I put a zwave module into the thermostat and have it working along with the wifi module. The standard Vera zwave thermostat device is working fine with Alexa. Thanks for your help.

jbonzey commented 7 years ago

Hi Hugh - I spoke too soon. Turns out the 2gig module works but there are issues. I would love to get everything working through your wifi code as it's so much cleaner and stable. Any help/suggestions above would be greatly appreciated. Thanks a lot.

jbonzey commented 7 years ago

alexa-radiothermostat-master.zip

These are the files I've used that are modified