Passing custom values to a command_switch

I am using a spark.io Photon to control a couple of pumps (pool and bore).

I want to use HA to schedule when these run, possbily use the input from the solar panels to run them a bit smarter. I also want to be able to run these manually.

I can call the function via a POST, with a string argument of the form “PP1300”,

PP - Identifier (Pool Pump)
1 - On or Off (1 is on)
300 - time in seconds (300 seconds / 5mins)

This is easily accomplished for static times, however i would like to be able to manually adjust the run time by manipulating the time in seconds.

Is it possible to build the string in HA?
How else could i do it? (ie start it with a long timeout, then have HA execute the time out by triggering the off condition)

thanks in advance.

Palitu

Hello Palitu,

This should help you out http://m.instructables.com/id/Spark-Core-Photon-and-CloudMQTT/?ALLSTEPS

Thanks,

that gives me an alternative comms protocol to the device, but i guess my real question was how i could make a variable that changes depending on an input into HA.

Ie have a dial or something so i can set 5, 10, 15, 20 minutes then alter the command accordingly. I dont think the MQTT would help.

Well it actually does help. It shows you you can work it to have it post to your own mosquitto server.

Point it to the one you are using for HASS and subscribe to the topics created for your PHOTON and your good to go.

[color=#0040BF]4.In the “mqtttest.ino” Line 29 :
client.connect(“sparkclient”);
change it to :
client.connect(“HASSMQTT-URL”, “HASSMQTTCLIENTuserid”, “HAMQTTCLIENTpassword”);[/color]

and

You can download the program from this link: github.com/CloudMQTT/python-mqtt-example

[color=#0040BF]Change this line with your HASSMQTT-URL:

Parse HASSMQTT-URL(or fallback to localhost)

    url_str = os.environ.get([b]'HASSMQTT-URL[/b]', 'mqtt://localhost:1883')
    url = urlparse.urlparse(url_str).[/color]

You can then use HASS in combination with the PHOTON. Look at input_boolean and input_select for your seconds issue.

AH, it is the input select that i am looking for. I am already using the restful api to talk to the photo, via command_switch and a curl post, hence the confusion around what MQTT has to do with it.

but the input_select should be the way to go.

Now, let me see if i understand it’s use (for a pool pump example):

  1. create a list of typical time values
  2. build my POST arguments to use the variable associated with my input selection.

I am trying to find out where i can find all the variables that are available to use in my HASS implementation, any suggestions on that?

Thanks.

looking at the component input_select.py,

it looks like that variable (is that the correct term for it?) is “select_option”

can the list be found in the “Set State” developers options

(sorry i am at work and cannot access my HASS instance to test)

cheers,

ok - so i have learnt how to use the select_input - close enough for now.

the next step is using the select.pooltime value in another string.

anyone have any info how i can use that in other commands? i have seen some things in {{ }}, but i am not sure of where to look for the context.

advice?!

ta,

Check out templating: home-assistant.io/getting-started/templating/

1 Like