As I understand more I WILL edit this question. For now, I am guessing at what I need. To make it easier for people to help, I'll tell you the over all purpose:

I have programmed an ESP8266 to advertise it is the TV and that it can turn the TV on / off. The ESP8266 actually transmits the absolute on / off codes to the TV using IR signals. I believe I have added a second "advertisement" for yet another on / off feature to the same ESP8266 device.

However, what I really want to add is a "relative volume" device. I believe I need to do this by using XML. That is, I believe I need to modify the XML transmitted to Alexa to not only advertise the on / off device but to also advertise a relative volume device.

Where can I find examples where a relative volume device is advertised to Alexa?

To clarify my objective, let me add an example:

If I say

"Alexa, turn on the TV"

the TV will turn on. But, if I say

"Alexa, turn up the volume on the TV"

Alexa will respond

"TV does not support that"

I started by using the code here in this github.com project and added additional code to handle transmitting the IR signals to the TV. This project appears to transmit this XML in response to an Alex asking for what the ESP8266 is capable of doing:

     HTTP.on("/eventservice.xml", HTTP_GET, [](){
      Serial.println(" ########## Responding to eventservice.xml ... ########\n");

      String eventservice_xml = "<scpd xmlns=\"urn:Belkin:service-1-0\">"
        "<actionList>"
          "<action>"
            "<name>SetBinaryState</name>"
            "<argumentList>"
              "<argument>"
                "<retval/>"
                "<name>BinaryState</name>"
                "<relatedStateVariable>BinaryState</relatedStateVariable>"
                "<direction>in</direction>"
                "</argument>"
            "</argumentList>"
          "</action>"
          "<action>"
            "<name>GetBinaryState</name>"
            "<argumentList>"
              "<argument>"
                "<retval/>"
                "<name>BinaryState</name>"
                "<relatedStateVariable>BinaryState</relatedStateVariable>"
                "<direction>out</direction>"
                "</argument>"
            "</argumentList>"
          "</action>"
      "</actionList>"
        "<serviceStateTable>"
          "<stateVariable sendEvents=\"yes\">"
            "<name>BinaryState</name>"
            "<dataType>Boolean</dataType>"
            "<defaultValue>0</defaultValue>"
           "</stateVariable>"
           "<stateVariable sendEvents=\"yes\">"
              "<name>level</name>"
              "<dataType>string</dataType>"
              "<defaultValue>0</defaultValue>"
           "</stateVariable>"
        "</serviceStateTable>"
        "</scpd>\r\n"
        "\r\n";

      HTTP.send(200, "text/plain", eventservice_xml.c_str());
});

I assume, in order to support (offer up to Alexa) relative volume control, all that needs to be done is add a description of the volume control feature to the above XML. However, I have not been able to find out how to do that.

  • 1
    It might help to point to the spec for the advertisements you are talking about – hardillb Sep 28 at 13:02
  • Are you sure you are not using the WeMo uPnP/Soap messages to pretend to be a WeMo switch? If so you can not do Volume/% changes only on/off – hardillb Sep 28 at 13:05
  • Yes, I am starting with a WeMo example. Is there a better example to start with? I used the word "advertisement" as I don't really know what to call it. In the WeMo example the ESP8266 transmits an answer to an Alexa discovery. It appears to advertise what the ESP8266 is capable of controlling. On an Amazon web page (lost to me at the moment) there is a description of all kinds of things an IoT device can do. Including on/off, relative volume and absolute volume. – st2000 Sep 28 at 13:26
  • Added link to github.com project that formed the bases of what I am working on. Also added the XML where, I believe, if the correct lines were added, would allow Alexa to control my TV's volume using this ESP8266 device. – st2000 Sep 29 at 2:50
  • Thanks - that should make this question easier for other people to find with a search. – Sean Houlihane Sep 29 at 8:16
up vote 3 down vote accepted

I don't believe you can do this with a local only device. The WeMo support is a legacy approach that has very limited capabilities.

You need to build an Alexa Smart Home Skill which requires a cloud component (With a lambda to trigger it).

The skill reports the capabilities of the device. (https://developer.amazon.com/docs/smarthome/smart-home-skill-api-message-reference.html#discovery-messages)

  • When you say a "local only device" can you explain what you mean? And by legacy are you hinting this approach is no longer used? – st2000 Sep 29 at 2:47
  • Local only means just that, no cloud involvement. And by legacy I mean that there has been a suggestion that support for discovering local IP based (not ZigBee) devices will be dropped at some point. To do what you want you will need to write a proper Smart Home Skill – hardillb Sep 29 at 6:22
  • I very much want to keep control of my IOT items out of the cloud. I believe I have picked my projects carefully to do this. (i.e. Using ha-bridge on a RPI allows Alexa control but should keep the connected IOT devices off the internet.) I like your answer - but I am finding hints that I can do volume control if only I knew what to "advertise" to Alexa during a discovery. See the "example for an entertainment device" XML on this Amazon page. – st2000 Sep 29 at 15:56
  • You gave up control as soon as you added the Alexa. That link shows the JSON response from the cloud lambda to Alexa, not something local. It can not be done without a lambda, there is nothing to stop you writing your own (I have the node-red smart home skill) and hosting most of it yourself, but the lambda needs to live on AWS – hardillb Sep 29 at 16:01
  • Just to clarify when I say alexa I mean the whole Alexa system, the device and it's cloud backing service. The skill talks to the Alexa cloud service not the device directly – hardillb Oct 1 at 12:58

This question generated considerable interest (7 as of this writing). So I am posting a followup answer with a local only solution.

I have accepted @hardillb answer as I have yet to find a method allowing Alexa to control relative Volume using a local only device.

However, there is a way to control relative TV sound levels using a local only device. By using a device name like "TV sound" and phrases like "Alexa, turn up the TV sound", Alexa can be coaxed into thinking it is turning up and down the brightness of a device called "TV sound". In accepting this approach we are forced to use Alexa's absolute brightness levels while trying to control a relative sound level TV. The first thing we notice is that we can only turn down TV sound a few times before we exhaust Alexa's brightness range (Alexa jumps about 25% for each dimming command). But we can also tell Alexa the brightness our device is set to at the end of each command. If we tell Alexa the brightness is always 50% then Alexa will always respond with more than 50% when we tell Alexa to "turn up TV sound" and less than 50% when we tell Alexa to "turn down TV sound".

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.