Nerkyator
(Nerkyator)
January 29, 2017, 11:21am
1
I have a problem with Haswitch in HADashboard.
I need a simple on\off button in Hadashboard connected to a switch in HA but I cannot get it to work.
My switches.yaml
configuration is this:
- platform: command_line
switches:
kitchen_led_strip:
command_on: mosquitto_pub -V mqttv311 -h IP_ADDRESS -t "CMD/ON" -m ""
command_off: mosquitto_pub -V mqttv311 -h IP_ADDRESS -t "CMD/OFF" -m ""
value_template: '{{ value == "1" }}'
and it is working on the HA panel without any problems.
So I wanted to add same “button” in dashboard and I added this in main.erb:
<div data-id="kitchen_led_strip" data-view="Haswitch" data-icon="sliders" data-title="LED" data-color="#FF0000"></div>
After pressed, it changes its status but does nothing at all. Looking in thin.log
I can see
2017-01-29 11:05:48 - NoMethodError - undefined method `strip' for #<Hash:0x7823ce68>:
/home/purcazzo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http/header.rb:18:in `block in initialize_http_header'
/home/purcazzo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http/header.rb:16:in `each'
/home/purcazzo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http/header.rb:16:in `initialize_http_header'
/home/purcazzo/hadashboard/jobs/homeassistant.rb:22:in `ha_api'
/home/purcazzo/hadashboard/jobs/homeassistant.rb:45:in `block in <top (required)>'
Am I missing something?..
aimc
(Andrew Cockburn)
January 29, 2017, 1:16pm
2
Hmm, if I had to guess I would say there is a problem with your $ha_apikey
variable in ha_conf.rb
.
Nerkyator
(Nerkyator)
January 29, 2017, 9:24pm
3
Thanks for response!
Uhm…on the same dashboard I have two Hasensor and a customized Google News widget working so I don’t think is related to ha_apikey
…unless I’m missing something, of course
aimc
(Andrew Cockburn)
January 30, 2017, 12:33am
4
Can you verify what is at line 22 of your homeassistant.rb please? Just copy and paste the line of code.
Nerkyator
(Nerkyator)
January 30, 2017, 9:56am
5
Sure!..here it is
request.initialize_http_header({"x-ha-access" => $ha_apikey, 'Content-Type' =>'application/json'})
(sorry for late response)
aimc
(Andrew Cockburn)
January 30, 2017, 12:39pm
6
OK, can you post your ha_config.rb please.
Nerkyator
(Nerkyator)
January 30, 2017, 1:12pm
7
of course:
$ha_url = "http://127.0.0.1:8123"
$ha_apikey =
$news_feeds = {
"Traffic" => "http://api.sr.se/api/rss/traffic/2863",
"News" => "https://news.google.it/news?cf=all&hl=it&pz=1&ned=it&output=rss",
"Google" => "https://news.google.it/?output=rss"
}
apikey is empty (not using it),I will add it when needed
aimc
(Andrew Cockburn)
January 30, 2017, 1:23pm
8
Mmm, can you try setting it to ""
at least.
Nerkyator
(Nerkyator)
January 30, 2017, 1:24pm
9
Ok, I will try when at home (right now I am at work) and I’ll let you know!
Nerkyator
(Nerkyator)
January 30, 2017, 5:02pm
10
It works! Thank you for your help @aimc !
1 Like